Boost logo

Boost :

From: John Maddock (john_maddock_at_[hidden])
Date: 2002-06-06 05:15:10


> I am relatively new to the regex library. I am trying to get all strings
> matched a a submatch 1, but where submatch 1 can match more than once
> because of *. ie
>
> Simplified version: "(?:\s*(\S+)\s+/)*\s+(\S+)"
>
> The problem is that i can't figure out how to force regex using regex_grep
> or what ever to give me each match in each sub-expression that occurs. ie.
> "xxx / yyy / zzz" will result in match yyy from sub-expression 1 and match
> zzz from sub-expression 2. But what about xxx?
>
> The expression i am using is to read filepaths from a config file:
>
> "^TAGFILES\\s+="
> "(?:"
> "\\s*(\\S+)\\s*\\\\$"
> ")*"
> "(?:"
> "\\s*(\\S+)[ \t]*$"
> ")"
>
> and example file content would be:
>
>
#---------------------------------------------------------------------------
> # Configuration::addtions related to external references
>
#---------------------------------------------------------------------------
> TAGFILES = D:/OPCrew/Src/TagFiles/Dil.tag \
> D:/OPCrew/Src/TagFiles/RunTests.tag \
> D:/OPCrew/Src/TagFiles/ScheduleSetServer.tag
> GENERATE_TAGFILE =
> ALLEXTERNALS = YES
>
>
> what to do? can this be done in one hit? should i take a different
approach?

As you've found that's not the way that regexes work: you only get whatever
the last match for each subexpression was. You will need to use a simpler
regex - one that matches just one path at a time and then grep through the
list.

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm


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