Substitutions work by editing the string being matched, but you want the substitutions to work on the string being returned. That doesn't work.
You could do it with a parser, but Perl 5 regexp are not good enough to form a parser. (Well, it's theoretically possible with experimental regexp features.)
In reply to Re^5: Regex: Capturing and optionally replacing
by ikegami
in thread Regex: Capturing and optionally replacing
by McDarren
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |