for example:
if i match "1+2+1" use "/[0-9](\+|\-)[0-9](\1)[0-9]
",it works,
but now i want to match "1+2-1",
but the regex "/[0-9](\+|\-)[0-9][^(\1)][0-9]/
" didn't work.
so how to match the "NOT \1"?
for example:
if i match "1+2+1" use "/[0-9](\+|\-)[0-9](\1)[0-9]
",it works,
but now i want to match "1+2-1",
but the regex "/[0-9](\+|\-)[0-9][^(\1)][0-9]/
" didn't work.
so how to match the "NOT \1"?
You may try to use negative lookahead and don't match it if it's the same as first matched char. You can fiddle around with this expression; [0-9]([+-])[0-9](?:(?!\1)[+-])[0-9]