I have a list of words, where some are the same. I need to find these duplicates to replace them with an empty string. I don't have any problems with the replacement inside python, but with the regular expression I try to use. This is an example of my list:
AC;AC MR;TA;AC MR;AC;AC MR;TA;SDA
The words are seperatet by a semicolon.
The expression I use is:
\b(\w+\s*\w+)\b;(?=.*\1)
I tried it without the spaces between the words like that:
AC;ACMR;TA;ACMR;AC;ACMR;TA;SDA
The result I get here, when I replace the matches with nothing is:
ACMR;TA;SDA
What I want as an result in the end is:
AC;ACMR;TA;SDA
You can see that there is no AC. He always matches the standalone AC and replaces it, when it comes before the ACMR. But these are different words and I need one of every word in my result.
Can someone help me with that? Thanks in advance