C
Chris Morris
This may be a case where RegExp ain't the way to go, but I want to scan
a string with nested paren groups and extract each outermost group. Is
this best done in an RegExp?
s = 'a group ( stuff ( other )) (( hey ( you ) (there) ) stuff )'
magic_re = # ?
s.scan(magic_re) { |match| puts match }
output:
( stuff ( other ))
(( hey ( you ) (there) ) stuff )
a string with nested paren groups and extract each outermost group. Is
this best done in an RegExp?
s = 'a group ( stuff ( other )) (( hey ( you ) (there) ) stuff )'
magic_re = # ?
s.scan(magic_re) { |match| puts match }
output:
( stuff ( other ))
(( hey ( you ) (there) ) stuff )