regex_search() return false for positive lookbehind and look
regex_search() return false for positive lookbehind and lookahead
我试图在C 11中使用regex_search
函数,而我的代码没有像我期望的那样找到字符串。
std::string regexString = "(?<=settings1)(.*)(?=;)";
std::regex rgx(regexString);
std::smatch match;
std::string settingValue;
if (std::regex_search("setting1=hellowSettingsWorld;", match, rgx)){
// match fond
settingValue = match[1];
cout << "string found " << settingValue << endl;
}else{
cout << "string not found "
}
我在Regex101上测试了这一正则表,它告诉我应该找到字符串" = hellowsettingsworld"
https://regex101.com/r/nu7qk5/1
但是std::regex_search()
总是返回false?
不确定我是否正在使用regex_search
功能错误或我的正则表达式是否有问题?
c <regex>
根据ecmascript(又称JavaScript)RegExp
实现,带有较小的扩展名来支持POSIX字符类。由于ecmascript RegExp
不支持look-behind,因此C <regex>
也不支持语法。
正如Casimir et hippolyte所建议的,如果您想要更多的花哨的正则表达式功能,请使用Boost Library。
相关文章:
- "error: no matching function for call to"构造函数错误
- 表示"accepting anything for this template argument" C++概念的通配符
- 如何在C++中从两个单独的for循环中添加两个数组
- 在Linux for Windows上编译C++代码时出错
- 调用专用模板时出错"no matching function for call to [...]"
- 为什么我的for循环不能正确获取argv
- 为什么我不能在 FOR LOOP 中使用 i/10,C++?
- Arduino:for/while/if在void setup()或void loop()之前?——错误:之前需要不合格
- 在基于范围的for循环中使用结构化绑定声明
- 通过for循环使用用户输入填充列表
- 使用for循环检查数组中的重复项
- 在for循环中使用auto vs decltype(vec.size())来处理字符串的向量
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 正在使用for循环创建QScatterSerie
- Python中的for循环与C++有何不同
- std::memory_order for std::atomic:<T>:wait
- 在更改for循环的第三部分后,未使用for循环结果
- 在 for 循环中查找问题时遇到困难
- 嵌套for循环C++的问题(初学者)
- regex_search() return false for positive lookbehind and look