正则表达式和增强
Regular expression and Boost
我对提升中的以下正则表达式有问题:
const boost::regex eComment("^/*[sS]*?*/|^//");
当我使用此正则表达式运行程序时,它中止并显示消息:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::regex_error> >'
what(): Invalid preceding regular expression prior to repetition operator.
The error occured while parsing the regular expression: '^/*[sS]*?*>>>HERE>>>/|^//'.
此正则表达式应该*.cpp
文件中找到带有注释的行,但如果行中有代码,则应跳过。
我认为
问题是你忘记转义反斜杠字符。每个反斜杠应加倍,如 \\s\\S 而不是 \s\S
希望对你有帮助
相关文章:
- 使用正则表达式regex_search在字符串中查找字符串
- 在 C++ 中使用正则表达式错误时出现问题 括号表达式中的范围无效
- C++ 使用增强正则表达式库时断言崩溃
- 在带有brew的MacOS上链接时缺少增强ICU正则表达式符号
- C++ 增强正则表达式与标准库正则表达式匹配结果
- 这种使用增强正则表达式库有什么问题
- 正则表达式和增强
- 如何使用增强正则表达式替换方法
- 如何使用增强正则表达式在单行中匹配单词
- 使用 VS2010 C++/增强的正则表达式
- 通过从文件读取来增强正则表达式匹配
- 正则表达式增强c++
- 正则表达式匹配组增强c++
- 增强特殊字符的正则表达式模式
- Qt正则表达式增强正则表达式转换从字符串内部取数
- 增强正则表达式捕获
- 增强正则表达式捕获组
- 使用增强正则表达式库编译程序时遇到问题
- C++ 增强正则表达式不保存捕获
- 增强正则表达式混淆