adsip
adsip

Reputation: 13

Regex that matches certain trailings of words with certain length?

How can I write a regex that matches the "e" trailings of every word, exept the "e" trailings of words with 2 or 3 letters?

Example:

abcdeeee: Full match for "eeee"

more: Full match for "e"

pie: No match

me: No match

Upvotes: 0

Views: 47

Answers (1)

L3viathan
L3viathan

Reputation: 27273

Use a lookaround assertion:

e+(?<=\w{4})\b

This matches e characters if afterwards there have been 4 word characters before the final e. The \b makes sure it ends at a word boundary

Demo

Upvotes: 1

Related Questions