I am trying to remove duplicate values from the following text:
[John Smith][John Smith][Jane Doe][Jane Doe][Doe][John][Smith John][John Smith Sr]
However, I need to treat each group of words inside the brackets as a unique value. That way, if a single word appears inside multiple brackets, but the group of words inside the brackets differ, I keep all values.
Using my sample text I expect to get the below,
[John Smith][Jane Doe][Doe][John][Smith John][John Smith Sr]
But instead I get the following text when using this RegEx (?:\[)(.+)(?:\])(?=.*\b\1,?)
[Jane Doe][Doe][Smith John][John Smith Sr]
Where am I going wrong? Appreciate any help I can get.