"Regexle #9" was originally published on kevingimbel.de.


Regexle #9

Todays regex had me confused! I kept thinking the solution was strings starting with v[aeiou], then strings ending [ing] or [m|n]e, but in the end the solution was a lot simpler.

The regex today was: [nm].$

This matches the end of strings (as indicated by the $ (dollar sign)). The regex itself matches n or m ([nm]) followed by exactly one character (. (dot)).

This matches strings ending in ing as well as strings ending in me and ne. Once again I was thinking way too complicated and didn’t see the pattern. I hope daily Regexle can sharpen my mind to recognise these sort of string patterns.

All in all it took me 24 tries and 4 regexes, my solution was /ing$|[mn].$/, which matches the patterns but is unnecessarily complex.