Boost logo

Boost :

From: Lorenzo Bettini (bettini_at_[hidden])
Date: 2007-05-01 11:31:13


John Maddock wrote:
> Lorenzo Bettini wrote:
>> do you happen to know whether there are any specifications for regular
>> expressions for matching parenthesis (I mean in any regexp frameworks
>> or libraries)?
>
> Not really no, but I have another idea, assuming the x-modifier is on:
>
> (?x)
> (?:
> (\()
> |(\[)
> |(\{)
> )
> foo
> (?:
> (?(1)\)
> |(?:(?(2)\]
> |(?:\}
> ))))
>
> The idea is to use conditional expressions to check which opening backet
> matched and then react accordingly. You'll need to check I've got the ('s
> and )'s matching up 'cos I lost count while typing in :-(
>

that's actually what I myself thought I might turn to if there was no
way of matching parenthesis (or brackets) with regular expression syntax
I was asking for :-)

I'll see whether this technique makes my regular expressions harder to
read than a simple copy and paste solution.

I thought there might be a syntax for it because I read in the regex
documentation, in the section "Character classes that are supported by
Unicode Regular Expressions" these syntaxes

Ps Open Punctuation
Pe Close Punctuation

and I thought they might be related (by the way, I actually did not
understand what they're for, since there's no example).

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