Boost logo

Boost Users :

Subject: [Boost-users] Boost.Regex for variable argument term?
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2010-10-29 09:44:37


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?

TIA

-- 
Met vriendelijke groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl



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