I am trying to write a single regex which matches strings
"A","B","AB"
and which does not match
"","AA","BB","BA"
I tried a simple pattern
re.search(r'^(A)?(B)?',sample_str)
But this pattern matches ""
.
I know many solutions which can match this by performing logical operations on multiple patterns but is it possible to match using a single pattern?
Thank you in advance.