Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2005-04-26 01:07:00


Is there a way to find out either the string, begin/end iterator or even
the position of the regex string that created a sub_match?

Lets say I have a regex parser that allows a dynamically defined regex to
be passed (say, user defined, from a config file).

So A user might pass:
Bla (.*) blerk (.*)
([[:digit:]]+) Bla .* ([[:alpha:]]*)

Or pretty much any regex (actually, in my case, this is not completely
true, however lets just say for argument's sake ...).

Now assuming another arbitary string is passed to this function, and it
matches the user-passed regex. How do I find out what the REGEX was that
matched this particular sub_match (or the position in the passed regex).

For example, if the second regex above was passed, I know by looking at it
that matches[1] was 'created' by ([[:digit:]]+) and matches[2] was
'created' by ([[:alpha:]]*). However programatically, I cannot find out.

Why can sub_match not include a mfirst and msecond parameter (and mstr()
function), that like first and second (and str()), will point to the
beginning and end, but of the regex string instead of the 'input' string.

PreZ :)
Founder. The Neuromancy Society (

Boost list run by bdawes at, gregod at, cpdaniel at, john at