public static string RemoveMany(this string dirtyString, params string[] stringsToRemove)
{
return dirtyString.Split(stringsToRemove, StringSplitOptions.None)
.Aggregate((sentence, next) => sentence + next)
{
return dirtyString.Split(stringsToRemove, StringSplitOptions.None)
.Aggregate((sentence, next) => sentence + next)
}
string dirty = "This is ABCa st)r(ing.";
string dirty2 = "tDEFes.t-";
string[] delims = new string[] { "ABC", "(", ")" };
Console.WriteLine(dirty.RemoveMany(delims));
Console.WriteLine(dirty2.RemoveMany("DEF", ".", "-"));
//output
"This is a string."
"test"
Hiç yorum yok:
Yorum Gönder