Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 学习boost::regex,匹配通配符_C++_Regex_Boost Regex - Fatal编程技术网

C++ 学习boost::regex,匹配通配符

C++ 学习boost::regex,匹配通配符,c++,regex,boost-regex,C++,Regex,Boost Regex,我刚刚开始学习regex 我需要匹配如下内容: hostname21.processName 是锚。前锚和后锚由[a-zA-Z0-9_33;]表示,但我不确定如何匹配锚两侧的两个条件 如果有帮助的话,我正在使用boost::regex 编辑 我用boost::regex reg(“[a-zA-Z0-9\]+\.[a-zA-Z0-9\]+”)尝试了Jerry的代码成功了。谢谢大家。我会使用reg((\w)+\.(\w)+”)你的意思是这样的:[a-zA-Z0-9\]+\.[a-zA-Z0-9\]

我刚刚开始学习
regex

我需要匹配如下内容:

hostname21.processName
是锚。前锚和后锚由
[a-zA-Z0-9_33;]
表示,但我不确定如何匹配锚两侧的两个条件

如果有帮助的话,我正在使用
boost::regex

编辑


我用
boost::regex reg(“[a-zA-Z0-9\]+\.[a-zA-Z0-9\]+”)尝试了Jerry的代码成功了。谢谢大家。

我会使用
reg((\w)+\.(\w)+”)你的意思是这样的:
[a-zA-Z0-9\]+\.[a-zA-Z0-9\]+
?这似乎不起作用。最好使用某种regex测试工具来学习使用regex。甚至可以是记事本+,如果你不想使用记事本,那么谷歌正则表达式测试网站。boost使用perl风格的正则表达式——它们非常流行。如果你想匹配你刚才指定的文本,你甚至可以写“*\\..*”-如果你真的想匹配点。@AleksanderFular记事本++实际上是个不错的主意,因为它实际上使用boost作为正则表达式引擎(至少在记事本++6中是这样)。我也这么认为。Sublime认为,“TylerJandreau注意到,当你使用杰瑞的代码时,在C++代码中,你可能不得不重复一段时间。因此,作为一个字符串,它看起来像:
“[a-zA-Z0-9\]+\.[a-zA-Z0-9\]+”
,您可能希望在模式周围添加(regex)锚定,如
“^…$”