I have a simple Perl regex that should match a space between two characters and replace the space with a *. It's simply not working in some cases. The Perl line is this:
s/([A-Za-z0-9])\s+([A-Za-z0-9])/\1 * \2/g;
For example see below: (~> is my zsh prompt)
~> cat mwe
s t Subscript[r, 1]
~> perl -pe "s/([A-Za-z0-9])\s+([A-Za-z0-9])/\1 * \2/g;" < mwe
s * t Subscript[r, 1]
t Subscript[r, 1] isn't being matched. This is just an example. My file is much longer, and while the regex catches most correctly, I can't find a pattern to the ones it doesn't match (and should).
Vim seems to find everything correctly (after the appropriate regex syntax changes).
How can I go about solving this? How can I help diagnose the problem?
Thank you.