Remove non-constant duplicate words from strings in an array\list

Viewed 460

I'm trying to extract primary words from a large set of very long strings to simplify displaying it so...

Assuming we have a string array that outputs:

Something One
Something [ABC] Two
Something [ABC] Three
Something Four Section 1
Something Four Section 2
Something Five

How to remove the non-constant duplicate words like Something and [ABC] so that it only leaves the unique identifiers of each string like One Two Three and output this list:

One
Two
Three
Four Section 1
Four Section 2
Five

Knowing that:

  • A duplicate is; any word that repeats more than once in the list

  • {"One", "Two", "Three", ..} as said, are not constant and are just there for the example and could change to anything else like for example {"Alpha" "Bravo", "Charlie"} or {"Nu", "Xi", "Pi"} long as they don't repeat.

  • If a certain word exist (in this case) "Section 1", the word before stays with it So that "Something Four Section 1" would become "Four Section 1"

2 Answers
Related