in reply to A regexp to parse nested brackets containing strings
use strict; use warnings; my $textInner = '(outer(inner(most "this (shouldn\'t match)" inner)))'; my $innerRe; $innerRe = qr/ \( ( (?: [^()"]+ | "[^"]*" | (??{ $innerRe }) )* ) \) /sx; $textInner =~ /^$innerRe/g; print "outer: $1\n";
(Sorry, I took out the comments to debug. Feel free to re-add them.)
|
|---|