I have a situation where I can get one or both pairs of characters, and I also want to match.
For instance:
str = 'cddd a dfsdf b sdfg ab uyeroi'
I want to match any "a" or "b" or "ab". If "ab" gets together, I want to catch it as one match (not as two matches "a" "b"). If I get "ab", it will always be in that order ("a" will always precede "b")
I have:
/[ab]|ab/
But I'm not sure what abwill be a stronger match than [ab].
Thanks for the help.
source
share