Alex Bomb
Alex Bomb

Reputation: 63

What wildcard character in xpressive means the entire end of text?

With ANSI C PCRE I could extract sections and their content by means of:

(?ms)^\\[(.+?)\\](.*?)(?=\\n\\[|.\\z)

From [sec1] a = b [sec2] c = d I got [sec1] a = b and [sec2] c = d

But how i can do it in xpressive?

Upvotes: 2

Views: 156

Answers (1)

Eric Niebler
Eric Niebler

Reputation: 6177

If you're using the "dynamic" dialect, you can use exactly the same syntax as for PCRE. For example (untested):

using namespace boost::xpressive;
sregex rx = sregex::compile("(?ms)^\\[(.+?)\\](.*?)(?=\\n\\[|.\\z");

If you're using the "static" dialect of xpressive, the wildcard pattern is _ (in namespace boost::xpressive. It matches any character. If you want to match any character except a newline character, you can use ~_n. Finally, if you want to match any single character except a logical newline (\r, \n, \r\n, and Unicode variants), you can use ~_ln.

(Edit: fixed typo)

Upvotes: 2

Related Questions