g++:
g++ rule_match.cpp -o rule_match
#include <stdio.h>
#include <string>
#include <regex>
using namespace std;
string rule = "select\\b[^\\r\\n]*current_user" ;
int main(void)
{
string val = "select a current_user";
if (true == regex_match(val.c_str(), regex(rule))){
printf("match!!!!!!!!!!!!!!!!!!!!!!!\n");
}
return 0;
}
该C++代码示例展示了如何使用`regex_match`函数进行字符串匹配。程序定义了一个规则`select[^
]*current_user`,并尝试匹配字符串`selectacurrent_user`,如果匹配成功则输出提示信息。
3657

被折叠的 条评论
为什么被折叠?



