Hi...
I want to replace in a javscript structure like the one below every
occurence of "{#...}", "{?...}", "{+...}" and "{=...}" through
something different (also nested):
function() {
test1 = "{#Caption}";
test2 = "{#Te{?st}}";
test3 = "{+date.{0}}";
}
with this regular expression
my( $open ) = qr/{[=+#?]/;
my( $close ) = qr/}/;
my( $not ) = qr/[^{}]++/;
do {
$found = $text =~ s/
(
$open
(?: $not | (?1) )
$close
)
/replace($1)/esxg;
} while ( $found );
I can handle case "test1" and "test2" but the case "test3" won't work.
Could some help me how I can change the expression that it match
"{+date.{0}}" without bothering about the "{0}" (this could also be
"{foo}").
I try it with:
my( $not ) = qr/(?>(?:(?!$open)|(?!$close))+)/;
but that won't work.
Thanks and best regards. And please excuse my english, I hope you will
understand everything, otherwise ask me ;-)
T.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/