Okay, that's a legitimate reason, although it's considered polite to let people know that you're asking for assignment help in the original post.
AnomalousMonk has shown a way to do it in one line, although that solution doesn't modify the string.
If you want to evaluate code on the right-hand side of your search/replace regular expression, see the /e modifier in perlop.
In reply to Re^5: substitution in regular experssion
by Anonymous Monk
in thread substitution in regular expression
by aeqr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |