From: ts Date: 2004-10-05T23:25:05+09:00 Subject: Re: Regexp match question on interpolated strings... >>>>> "J" == James Edward Gray writes: J> expressions here. Perl's regex engine has no such limitation. Using J> the (?? ... ) construct, Perl regular expressions can parse balanced ^^ I've always find strange the choice for these 2 charcaters ... J> delimiters. I miss this feature and would love to see Ruby add J> something similar in the future. This ? svg% cat b.rb #!ruby -rjj ["(aaa(bbbc)xxx)", "(aaa(bb(b)c)xxx)"].each do |m| p $& if /(?\((?:(?>[^()]+)|\g)*\))/ =~ m end /(?\((?:(?>[^()]+)|\g)*\))/.dump svg% svg% ruby b.rb "(aaa(bbbc)xxx)" "(aaa(bb(b)c)xxx)" Regexp /(?\((?:(?>[^()]+)|\g)*\))/ 0 call 2 1 jump 19 2 mem-start-push 1 3 exact1 ( 4 push-if-peek-next ) ===> -1 5 null-check-start 0 6 push 13 7 cclass-not (-) (2) 8 push 12 9 cclass-not (-) (2) 10 pop 11 jump 8 12 jump 14 13 call 2 14 null-check-end-memst-push 0 15 jump 4 16 exact1 ) 17 mem-end-rec 1 18 return 19 end Optimize EXACT : ( svg% Guy Decoux