Let\'s say I have two strings like this:
XABY XBAY
A simple regex that matches both would go like this:
X(AB|BA)Y
try this
X((A|B){2})Y