Boost logo

Boost Users :

From: John Maddock (dr_john_maddock_at_[hidden])
Date: 2003-09-29 05:31:45

> The last assert always fails, because regex::match insists on including
> space after the ":" in the second match result, which seems wrong to me.
> I've tried giving various different combinations of flags to the regex
> although from what I can tell from the documentation the default flags
> should work. This is with VC7 and boost 1.30.2. For comparison, perl
> (5.6.1) does not seem to have this problem, as the following script
> illustrates:
> #!/usr/bin/perl
> print "matches: <$1> <$2>\n" if ('foo: bar' =~ /([\w]+):[\s]*(.*)/);
> Is there any way to get the behavior I want?

This is the difference between perl and POSIX leftmost-longest matching
rules showing itself (the next release will default to perl rules and do
what you want, but of course that doesn't help you now), basically
non-marked sections are neither greedy nor non-greedy under POSIX rules, so
regex finds the match it does because it makes $2 further to the left than
the alternative (without effecting the overall match). You can get the
effect you want by making your expression more "precise":


for example,


Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at