From: John Maddock (john_at_[hidden])
Date: 2003-12-10 06:41:20
> According to my understanding of regular expressions, all three should
> report the same things. But the Non Greedy example produces mangled
> I can't even understand how that output is being generated.
> Is this a Boost bug, or have I done something wrong?
You've done something wrong: in the non greedy version:
(.*?) : (.*?) , (.*?)
The final repeat ($3) matches a zero length string right before the "776"
part (because it's non-greedy remember).
So when generating the new string from "$1" it copies:
Everything from the start of the string to the start of the match : ""
Then $1 : "City 15"
Everything from the end of the match to the end of the text : "776"
To produce "City 15776" in all.
You can suppress copying of unmatched sections with the match_flag:
format_no_copy, but then you would loose the final 776 part altogether.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk