3
string str = "hello world!\r\naa=`xxx_1`\r\nhello world!";
sregex rx = sregex::compile(".+=`(.+)_1`");
smatch what;
if( regex_match( str, what, rx ) )
{
    std::cout << what[1] << '\n';
}

this can't work, i use boost.xpressive not boost.regex, how to match multi-line text?

travaller2
  • 351
  • 1
  • 2
  • 12

1 Answers1

5

i have resolved this problem.

http://boost-sandbox.sourceforge.net/libs/xpressive/doc/html/boost_xpressive/user_s_guide/matching_and_searching.html

The regex_match() algorithm will only report success if the regex matches the whole input, from beginning to end. If the regex matches only a part of the input, regex_match() will return false. If you want to search through the string looking for sub-strings that the regex matches, use the regex_search() algorithm.

travaller2
  • 351
  • 1
  • 2
  • 12