OR condition in Regex

Try

\d \w |\d

or add a positive lookahead if you don’t want to include the trailing space in the match

\d \w(?= )|\d

When you have two alternatives where one is an extension of the other, put the longer one first, otherwise it will have no opportunity to be matched.

Leave a Comment