Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Regex for variable argument term?
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-11-01 01:47:30


On Fri, Oct 29, 2010 at 7:44 AM, Joost Kraaijeveld
<J.Kraaijeveld_at_[hidden]> wrote:
> Hi,
>
> I am trying to make a regex that matches a term with an arbitrary number
> of arguments. It has the format:
>
> TERM KEY(-?PRE:COL[,-?PRE:COL]*)
>
> with at least 1 PRE:COL and at most N (comma separated) PRE:COL, each of
> them possible prefixe with 1 '-' char
>
> I have the following:
>
> ^([[:word:]])[[:blank:]]*KEY\\(-?[[:word:]]+:[[:word:]]+(,-?([[:word:]])+:([[:word:]]+))*\\)
>
> But this does not work: e.g. the string
>
> KEY1 KEY(TEK:KDE),NOCASE,OPT,PRIMARY
>
> has the following matches (notice the empty matches):
>
> what[0] = KEY1 KEY(TEK:KDE),NOCASE,OPT,PRIMARY
> what[1] = KEY1
> what[2] = TEK
> what[3] = KDE
> what[4] =
> what[5] =
> what[6] =
>
> and the string
>
> KEY1 KEY(RKM:KEN,RKM:REL,RKM:VAL),NOCASE,OPT,PRIMARY
>
> has the following matches (notice match 4 and the lack of the last
> PRE:COL pair):
>
> auxWhat[0] = KEY1 KEY(RKM:KEN,RKM:REL,RKM:VAL),NOCASE,OPT,PRIMARY
> auxWhat[1] = KEY1
> auxWhat[2] = RKM
> auxWhat[3] = KEN
> auxWhat[4] = ,RKM:VAL
> auxWhat[5] = RKM
> auxWhat[6] = VAL
>
> Is there a regex that sort of does does what I want?

Slightly offtopic, sounds better suited to Boost.Spirit.Qi.


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