我想匹配以下字符串,但始终收到false且match为空。仅当表达式等于字符串时,返回值才为true。我的正则表达式似乎是正确的。我究竟做错了什么?
#include <regex>
using namespace std;
int main()
{
regex rgx("use_gui=((true|false)); state=((bla|blub|blob))");
cmatch cm;
string s("use_gui=false; state=bla");
bool ret = regex_match(s.c_str(), cm, rgx);
}
考虑删除多余的括号:
regex rgx("use_gui=(true|false); state=(bla|blub|blob)");
这固定它适合我。(感谢@Lightness Races在轨道上向我展示coluru)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句