[英]Boost::regex_match isn't firing
I have some boost Regex code which I think should fire. 我有一些Boost Regex代码,我认为应该触发。 I'm new to boost but I know a little bit of Regex. 我是新手,但我对Regex有所了解。 Here's the code that I'm using. 这是我正在使用的代码。
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))
and here is the test string I'm using. 这是我正在使用的测试字符串。
this is a test
-------- Original Message --------
everything under here should disappear
My code compiles and runs, it just doesn't trigger the if statement. 我的代码可以编译并运行,只是不会触发if语句。 I tried debugging into the boost code and ... yeah... 我尝试调试升压代码,然后...是的...
regex_match regex_match
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. regex_match算法确定给定的正则表达式是否与一对双向迭代器表示的所有给定字符序列匹配 ,算法定义如下,该函数的主要用途是数据输入验证。
regex_search regex_search
The algorithm regex_search will search a range denoted by a pair of bidirectional-iterators for a given regular expression. 算法regex_search 将搜索由一对双向迭代器表示的范围,以获取给定的正则表达式。 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: 该算法定义如下:
So, use boost::regex_search
. 因此,请使用boost::regex_search
。 Example. 例。
http://liveworkspace.org/code/fa35778995c4bd1e191c785671ab94b6 http://liveworkspace.org/code/fa35778995c4bd1e191c785671ab94b6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.