Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2005-08-02 02:16:56


On 8/2/05, Merrill Cornish <merrill.cornish_at_[hidden]> wrote:
> I am using regex_match() from Boost 1.32.0. I am well famililar with Perl's regular expression, but I got a surprise from Boost's regex_match(). My basic code is
>
> static const regex CHAR(" char ");
> regex_match(newSpec, CHAR)
>
> If newSpec is " char ", then it matches, of course. However, if newSpec is " char * ", it doesn't match. Hmmmm.
>
> In my Perl experience, a regex of " char " says match those six characters if found ANYWHERE in newSpec. This would mean that a Boost regex of " char " would match a newSpec of " char * ", but it doesn't seem to.
>
> If I change the regex to ".* char .*", then it matches, implying that Boost's regex of " char " is being treated as if it were Perl's "^ char $".
>
> I could add the ".*" before and after each of my (many) regular exressions. However, I'm guessing there is a match_flag_type value which would do this for me. Unfortunately, none of the match constant descriptions seem to be what I need.
>
> How should I write a Boost regex so that it would find " char " anywhere in the input string regardless of any prefix or suffix?
>
> Merrill

It's not the regex, it's the algorithm - use regex_search rather than
regex_match

HTH
Stuart Dootson


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