in reply to Re^2: string substitution
in thread string substitution

You should at least provide valid data in the sense of an SSCCE, your description is cryptic.

Anyway, ISTM you want a character class [^5] in the regex to match anything but 5.

Please expand the code provided to your needs, and show us what you tried.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery