how to simplify this regular expression

68 views Asked by At

how can I simplify this expression without so many ORs?

a(r|i|ir|ri|irr|rri|rr)(ba|b|ab)

The goal is to catch all of these variations:

ariba, airba, arba, arib, airb, arriba, arrba, airrba, airab, ariab

You can see it here: https://regex101.com/r/vbQRGF/1

1

There are 1 answers

1
ZimbiX On BEST ANSWER

If your goal is for it to shorter, then that is possible, but it will match more than what you've specified:

a[ri]{1,3}[ab]{1,2}