I have the following line:
The {quick} brown fox {jumps {over {deep} the} {sfsdf0} lazy} dog {sdfsdf1 {sdfsdf2}
And the PHP regular expression:
/(?=\{((?:[^{}]+|\{(?1)\})+)\})/g
It gives the following matches:
[5-10] `quick` [23-60] `jumps {over {deep} the} {sfsdf} lazy` [30-45] `over {deep} the` [36-40] `deep` [48-54] `sfsdf0` [76-83] `sdfsdf2`
See: http://regex101.com/r/fD3iZ2 .
I am trying to get an equivalent working in Ruby, but I have a problem with (?1) ... the result is an undefined group option error:
str = "The {quick} brown fox {jumps {over {deep} the} {sfsdf} lazy} dog {sdfsdf {sdfsdf}" str.scan /(?=\{((?:[^{}]+|\{(?1)\})+)\})/ SyntaxError: undefined group option: /(?=\{((?:[^{}]+|\{(?1)\})+)\})/
See: http://fiddle.re/n6w4n .
Coincidentally, I get the same error in Javascript and Python.
My regex foo is almost exhausted today, any help is much appreciated.
source share