Regex question


I’d like to replace all the ‘e’ which are not preceded and followed by an alphanumeric char.

hex -> no
2+e -> yes
e-1 -> yes

I made the following reggae but it seems not to work properly.


Where is my error?


Your pattern requires such a character both before and after the “e”, which is not what you want. It’s also a good time to use a lookaround. Try this:


This will match an “e” if it meets one of those conditions using negative lookarounds.

thanks Kem. perfect as usual.