I\'m trying to match text like sp { ...{...}... }, where the curly braces are allowed to nest. This is what I have so far:
sp { ...{...}... }
my $regex = qr/ (
There are numerous problems. The recursive bit should be:
( (?: \{ (?-1) \} | [^{}]+ )* )
All together:
my $regex = qr/ sp\s+ \{ ( (?: \{ (?-1) \} | [^{}]++ )* ) \} /x; print "$1\n" if 'sp { { word } }' =~ /($regex)/;