I have a situation where I might be getting one or both of a pair of characters and I want to match either.
For example:
str = 'cddd a dfsdf b sdfg ab uyeroi'
I want to match any "a" or "b" or "ab". If the "ab" comes together I want to catch it as a single match (not as two matches "a" "b"). If I get "ab" it will always be in that order ("a" will always precede "b")
What I have is:
/[ab]|ab/
But I'm not sure if the ab
is going to be a stronger match term than the [ab]
.
Thanks for the assistance.