I need to match incorrect backslashes in a text. The following text is an example:
\.br\ Random Words \.br\\1 Testing\.br\2\ Check
So the \.br\ are correct, however the backslashes in \1 and 2\ are not.
So I attempted a regular expression to match any \ which is not followed by a .br but that failed because it would match the closing \ in \.br\
I then looked up a few similar questions on stackoverflow and most of them stated that a series of lookaheads can be used as an 'and' operator and so I tried this:
/(?!\\\.br)\\(?!\.br\\)/
What I attempted to do, was match any backslash that was neither precedeed by a \.br nor followed by a .br\ but it didn't seem to work.
Any help would be appreciated. I hope I haven't missed out any details in the question.
Thanks,
Sid