|
Boost Users : |
Subject: Re: [Boost-users] How to use Boost Regex Partial Match
From: John Maddock (john_at_[hidden])
Date: 2009-04-15 08:06:00
> Given this code. I expect to get this output from the corresponding
> input:
>
> Input: FOO Output: Match
> Input: FOOBAR, Output: Match
> Input: BAR, Output: No Match
>
> But why it gives "No Match" for input FOOBAR?
You - possibly - have the regex and the string the wrong way around.
You are trying to match the regex "FOO" against the string "FOOBAR" and
regex_match will only succeed if the *whole of the string matches the
regex*, with the flag match_partial set then it will also return true if
*the whole of the string matches a prefix of the regular expression*.
If you really wanted to match all of the regex against a prefix of the
string (a more common situation) then use regex_search with match_continuous
set.
And of course, if you want to find an occurance of a regex somewhere within
the string then set no flags.
HTH, John.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net