I have a bad word list. If a string contains any of item/items from the bad word list, I need to remove that bad word from the string.
List<string> badWordList = new List<string> { "email:", "index", "mobile:", "fax:", "web" };
I am able to search the string but not able to remove. Please help me out...I tried below code:
string myText = "email:abc@gmail.com";
if (badWordList.Any(w => myText.IndexOf(w, StringComparison.OrdinalIgnoreCase) >= 0))
{
// How to remove
}
Below is the set of input of expected output:
i/p- email:abc@gmail.com
o/p - abc@gmail.com
i/p- Jack F. Mobile:89788987
o/p- Jack F. 89788987
i/p- Jack F. Email:t@p.c mobile:65777 WEB
o/p- Jack F. t@p.c 65777
I would prefer a non-regex approach. Thanks for your help.