boost之正则表达式

正则表示主要用于查找一系列符合规则的对象,而我们之前的查找是对某一特定的字符串进行查找。

#include <iostream>
#include <vector>
#include <string>
#include <boost/xpressive/xpressive_dynamic.hpp>
using namespace std;
using namespace boost;
using namespace boost::xpressive;

int main()
{
	string str;
	cregex reg = cregex::compile("a.c");
	if (regex_match("abc",reg))
	{
		cout << "Ok"<<endl;
	}
	if (regex_match("a+c",reg))
	{
		cout << "Ok"<<endl;
	}
	if (regex_match("abd",reg))
	{
		cout << "Ok"<<endl;
	}
	if (regex_match("ac",reg))
	{
		cout << "Ok"<<endl;
	}
	return 0;
}
原文地址:https://www.cnblogs.com/liuweilinlin/p/3261987.html