Boost logo

Boost :

From: Lorenzo Bettini (bettini_at_[hidden])
Date: 2007-05-01 05:41:28


John Maddock wrote:
> Lorenzo Bettini wrote:
>> Hi
>>
>> is there a way to specify open and closed parenthesis with a
>> regular expression syntax? For instance, if I'd want to specify a
>> single regular expression that matches both (foo) and [foo] and {foo}?
>
> Probably not what you wanted, but:
>
> [(\[{]foo[)\]}]
>

but this would match also {foo] which would wrong...

> sort of does what you want, but if you want to ensure that the brackets
> match up, then it's down to:
>
> \[foo\]|\(foo\)|\{foo\}

I see, this brings to lots of duplicated code (especially if the inner
part is big...

do you happen to know whether there are any specifications for regular
expressions for matching parenthesis (I mean in any regexp frameworks or
libraries)?

thanks
        Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net

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