I ended up coming up with this, which seems to work fine and avoids previously tagged cases, but the anchored version is better.
$text =~ s/(\bS\.(?=\s))/\<\1=initial\>/g;
In reply to Re^2: Regex is eating up whitespace
by gatito
in thread Regex is eating up whitespace
by gatito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |