I have a string
string name = \"AL QADEER UR AL REHMAN AL KHALIL UN\";
How would I remove all characters AL
, UR
,
No need to use regular expressions. Having defined list with "prohibited" words, it's enough to iterate over wprds in the sentence to filter, if word is in the list of prohibited words, then exclude it, otherwise, include the word in final string.
Try this:
string name = "AL QADEER UR AL REHMAN AL KHALIL UN";
string systemName = "";
List list = new List { "AL", "UR", "UN" };
foreach (var item in name.Split(new char[] { ' ', ',', '.' }, StringSplitOptions.RemoveEmptyEntries))
systemName += list.Contains(item) ? "" : item + " ";