
Paul Giaccone wrote:
Lorenzo Bettini wrote:
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...
You could use Spirit, of course, using a function that recorded which type of bracket (pedantic point: "(", "), "[", "]", "{" and "}" are all brackets, but only "(" and ")" are parentheses) was found first and
yes, sorry: in Italian they're all called parentheses :-)
I'd suggest seeing if anyone else comes up with a solution using regex, and writing your own simple parser by hand (not using Spirit) if not.
I heard about Spirit, and I'll probably take a look at it... 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