C++ boost

C++ boost 正则表达式用法

℡╲_俬逩灬. 提交于 2019-12-17 12:33:59
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 什么是正则表达式?正则表达式是一种用来描述一定数量文本的模式。Regex代表Regular Express。 如果您不知道什么是正则表达式,请看这篇文章http://blog.csdn.net/begtostudy/archive/2007/11/11/1879206.aspx 有了正则表达式的基础,问题是如何使用。我们以boost::regex来说 先看一个网上经典的例子。 #include "stdafx.h" #include <cstdlib> #include <stdlib.h> #include <boost/regex.hpp> #include <string> #include <iostream> using namespace std; using namespace boost; regex expression("^select ([a-zA-Z]*) from ([a-zA-Z]*)"); int main(int argc, char* argv[]) { std::string in; cmatch what; cout << "enter test string" << endl; getline(cin,in); if(regex_match(in.c_str(),