The only way I can think of is with using index() to find the position of the string to replace:
my $template = 'aaa <%xx%> bbb'; my $repl = substr $template, index($template, '<%xx%>'), length('<%xx% +>'), '//div[@id="abc"]'; print $template; # aaa //div[@id="abc"] bbb
In reply to Re^2: Elegant way to escape a string in a regex
by Anonymous Monk
in thread Elegant way to escape a string in a regex
by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |