You should use $1 instead of \1 in the substitution. < and > are not magical in regexen and, apart from $, there are no magical characters in the substitution string in any case - you do not need to escape < and >. Perl allows you to use different delimiters for regexes which can often make the regex much easier to read. Consider:
$text =~ s!(\bS\.(?=\s))!<$1=initial>!g;
In reply to Re^3: Regex is eating up whitespace
by GrandFather
in thread Regex is eating up whitespace
by gatito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |