I’m trying to use regex to match: a word that’s at least 5 characters long and ends with an ‘s’, but the ‘s’ is included in the 5 characters. Say for example, I have the following words:
hexes pixies major prairies caveman zipfiles oxes
I tried doing ([a-z]s?){5,}
>Solution :
The pattern ([a-z]s?){5,} repeats 5 or more times a character in the range a-z followed by an optional s char
If you only want to match characters a-z and "words" are determined by word boundaries \b, you can match 4 or more times the range a-z and end the match with an s char
\b[a-z]{4,}s\b