From: "Stephan Kämper" Date: 2002-02-27T00:25:39+09:00 Subject: Re: Nested paired brackets in regexp Yasuo Saito wrote: > > Hi. > > Ruby's regular expression is very powerful. > > But, I cannot express paired brackets(<...>), which > might be nested, in a single regular expression. > > How can I check nested paired brackets by a single/simple > (extended) regular expression, if possible? > > eg. > input | expected > ------------------+-------------- > "abef" | "" > "abe" | "" > "abfg>h>i" | "gh>i>" > "abf" | not matched > > Y.Saito If I remember corretly what I've read in Friedl's "Mastering Regular Expressions" (O'Reilly), there's a principal reason why matching nested pairs of brackets (or whatever can be paired) isn't possible. Note that there _are_ ways to match paired braces up to a certain nesting level (if you like I can check in my copy of Friedl's book, I just don't have it at hand right now...). Hope that helps Stephan