I need a regular expression that matches either 8 letter words ending in "tion" or 10 letter words ending in "able".
Here is what I came up with, but for some reason http://regex101.com tells me there are no matches when I try to match a string.
My idea is as follows:
([a-z]{4}^\btion\b|[a-z]{6}^\bable\b)
Link to regex101 - Here
Try this one:
\b([a-z]{4}tion|[a-z]{6}able)\b
You use ^\b
between the variable section (e.g. [a-z]{4}
) and constant postfix (e.g. tion
) and that breaks the match. ^
means "beginning of the string (or a line)" and \b
means "word boundary". Using it together makes little sense, as beginning of the string is always a word boundary.