Your solution has two problems:
1) Injection Vulnerability
You don't escape the %s in $1 and $'. Pass them as arguments to printf instead, adding %s in the format string where necessary
2) Performance Leak
Using $' can cause other (unrelated) regexp in your program to slow down. Add (.*) to the end of the regexp and use $2 instead of $'.
In reply to Re^2: In place edit and printf
by ikegami
in thread In place edit and printf
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |