Something like this should work:
static void Main(string[] args)
{
string[] searchElemnts = new string[] { "öne", "two","three", "four" };
string[] samples = new string[] { "öne_two", "öne_two_three","öne_two_three_four", "öne]two[three-four" };
string[] copySamples = samples.ToArray();
for (int i = 0; i < copySamples.Length; i++)
{
foreach (string element in searchElemnts)
{
copySamples[i] = copySamples[i].Replace(element, "");
}
}
char[] unwantedChars = string.Join("",copySamples.ToArray()).ToCharArray().Distinct().ToArray();
Regex regex = new Regex("[" + Regex.Escape(new string(unwantedChars)).Replace("]", "\\]") + "]");
string result = "";
for (int i = 0; i < samples.Length; i++)
{
result = regex.Replace(samples[i], "-");
System.Diagnostics.Debug.Print(result);
}
}
What this code do is:
-Anything other that searched elements are assumed as unwanted character.
-Prepares a list of unwanted characters,
-Replace each unwanted character with "-".
Hope that helps!