I have a string
string name = \"AL QADEER UR AL REHMAN AL KHALIL UN\";
How would I remove all characters AL
, UR
,
Pure LINQ
answer with the help of EXCEPT
string name = "AL QADEER UR AL REHMAN AL KHALIL UN";
var list = new string[] { "AL", "UR", "UN" };
name = name
.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.Except(list)
.Aggregate((prev, next) => $"{prev} {next}");
OUTPUT: QADEER REHMAN KHALIL