string inputString = "1/10 EP Sp'arrowha?wk XT R;TR 2.4GHz Red";
//Characters Collection: (';', '\', '/', ':', '*', '?', ' " ', '<', '>', '|', '&', ''')
string outputString = "1 10 EP Sp arrowha wk XT R TR 2.4GHz Red";
Full disclosure regarding the following code:
new Regex(...)
;I don't actually know C#, but I can Google for "C# string replace regex"
and land on MSDN
Regex re = new Regex("[;\\/:*?\"<>|&']");
string outputString = re.Replace(inputString, " ");
Here's the correct code:
string inputString = "1/10 EP Sp'arrowha?wk XT R;TR 2.4GHz R\\ed";
Regex re = new Regex("[;\\\\/:*?\"<>|&']");
string outputString = re.Replace(inputString, " ");
// outputString is "1 10 EP Sp arrowha wk XT R TR 2.4GHz R ed"
Demo: http://ideone.com/hrKdJ
Also: http://www.regular-expressions.info/
string outputString = Regex.Replace(inputString,"[;\/:*?""<>|&']",String.Empty)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With