Given the situation I got a string array from a file containing IDs.
Which may be separated by various characters, " " : ; etc.
I would like to obtain every string in one new list/array, using LinQ, that contained any of the given separators.
I am currently doing this in a rather inconvenient way
string[] separator = { " ", ",", ";", ".", ":", "/" };
string[] arr = { };
listExceptions = someSource;
List<string> entrysWithSeparator=
(from s in listExceptions where (ContainsAny(s,separator) == true) select s).ToList();
//ContainsAny returns a bool, if any of the separators was found in the string
List<string> tmpExceptions = listExceptions.ToList();
foreach (string s in entrysWithSeparator)
{
arr = s.Split(separator, StringSplitOptions.RemoveEmptyEntries);
tmpExceptions.AddRange(arr.ToList());
}
listExceptions = new string[listExceptions.Count()-1];
listExceptions = tmpExceptions.Distinct().ToArray();