I’m trying to write regex that can search for singular and plural forms.
re.search(r'dress(es\b|\b)','dresses') re.search(r'dress(es)?\b','dresses') re.search(r'dress[(es)\b]','dresses')
<re.Match object; span=(0, 7), match='dresses'> <re.Match object; span=(0, 7), match='dresses'> <re.Match object; span=(0, 6), match='dresse'>
Why does the 3rd method only match
dresse? I thought anything inside
 are alternatives of each other (select 1 option from
\b) so it has the same effect as the 1st two regex?
What differences are there between the first two regex? (eg. extensibility, robust against false positives).
How to achieve the same effect using square brackets in 3rd regex and how does that compare to first two regex?