Say I have a substring BB which may be alone or part of a longer string, e.g. BB or AA|BB|CC or BB|CC or AA|BB i.e. if it follows/is followed by another substring it MUST be separated by a |. What regex do i need to find BB in any of the above but not in say AABB?
I think this will do it:
^(.+[|])?BB([|].+)?$
And after testing here I'm going to say yes, this is it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With