gpt4 book ai didi

c++ - Boost::regex_match 没有触发

转载 作者:行者123 更新时间:2023-11-28 07:59:55 25 4
gpt4 key购买 nike

我有一些我认为应该触发的 boost Regex 代码。我是 boost 的新手,但我对 Regex 有一点了解。这是我正在使用的代码。

re = boost::basic_regex<TCHAR>(_T("-+\\s+Original\\s+Message\\s+-+"), boost::regex_constants::icase);
boost::match_results<TSTRING::const_iterator> result;
if(boost::regex_match(RawBody, result, re))

这是我正在使用的测试字符串。

this is a test

-------- Original Message --------

everything under here should disappear

我的代码编译并运行,只是没有触发 if 语句。我尝试调试到 boost 代码中......是的......

最佳答案

正则表达式匹配

The algorithm regex_match determines whether a given regular expression matches all of a given character sequence denoted by a pair of bidirectional-iterators, the algorithm is defined as follows, the main use of this function is data input validation.

正则表达式搜索

The algorithm regex_search will search a range denoted by a pair of bidirectional-iterators for a given regular expression. The algorithm uses various heuristics to reduce the search time by only checking for a match if a match could conceivably start at that position. The algorithm is defined as follows:

因此,使用 boost::regex_search。示例。

http://liveworkspace.org/code/fa35778995c4bd1e191c785671ab94b6

关于c++ - Boost::regex_match 没有触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11767483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com