Aside from this probably being an inadequate approach to solving the actual problem, you are using character set matches where you need anchors. Changing [^<] to (?<!<) avoids matching the preceding character, but ensures that it isn't <. Try:
$text =~ s/\b(?<!<)S\.(?!=)/<S.=initial>/g;
Remember that the substitution replaces all the characters matched so you must either capture and insert any "extra" matched characters or not match them in the first place (anchors don't "match" characters in this sense).
In reply to Re: Regex is eating up whitespace
by GrandFather
in thread Regex is eating up whitespace
by gatito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |