Reputation: 63
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
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