I have a simple Perl regular expression that should match the space between two characters and replace the space with *. In some cases, this simply does not work. The Perl line is this:
s/([A-Za-z0-9])\s+([A-Za-z0-9])/\1 * \2/g;
For example, see below: ( ~>- this is my zsh invitation)
~> 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]not mapped. This is just an example. My file is much longer, and when the regex snaps the most correctly, I cannot find a pattern that does not match (and should).
It seems that Vim finds everything correctly (after changing the syntax of the corresponding regular expression).
How can I solve this? How can I help diagnose the problem?
Thanks.
source
share