This is a generic regular expression question, that I couldn't find an answer too.
Lets say I have a few input strings:
...A-A-B...
...B-A-A...
...A-B-A...
...B-B-A...
I have two delimiters A
and B
. What I want to do is find either of these, and then look for the other one. Now I know I can do (A.*B)|(B.*A)
which will match what I want for all four strings.
And I can also do (A|B).*\1
which would match A-A
for the first and second strings, A-B-A
for the third and B-B
for the last.
Can I do something alongs the lines of (A|B).*[^\1]
to say, find one of two tokens then find the other token?
For context, I was interested in this because of this question, where A
and B
are a dot or comma for currency matching, but I figure this could be useful in lots of contexts, hence the generic question.