Boost logo

Boost :

From: Jason Dossett (jdossett_at_[hidden])
Date: 2001-01-16 12:36:03


I recently downloaded the latest boost release (great set of
libraries!) and built the regex lib for vc++.

I'm using the following to perform a regex match:

char line[4096];
cmatch match;

get_line(line);
if( boost::regex_match( line, match, boost::regex( "\\[(.+?\\]" ) ) )]
{
   do_stuff_with( match[1] );
}

(code simplified for the example)

The line I am performing the match on is something like this:
[SOFTWARE\SomeCompany\SomeProduct\SomeSubKey]

The regex_match is returning this for the submatch:
SOFTWARE\SomeCompany\SomeProduct\SomeSubKey]

I would think that the '?' would force the regex to be non-greedy,
and only get what was between the [].

I tested this with perl, and the same regexp resulted in this for the
submatch:
SOFTWARE\SomeCompany\SomeProduct\SomeSubKey

Is this a known problem with regex? Or am I overlooking something
simple?

Thanks for your time.

Jason Dossett
Sr. Software Engineer
SEP, Inc.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk