Stipping Invalid Characters from a String

First, it’s called “stripping!” Second, to strip these characters from a string, you must use the Regex.Replace method. — as denoted by microsoft here.

using System.Text.RegularExpressions

Regex.Replace(strInput, @”[^\w\.@-]”, “”);

This will strinp all invalid characters EXCEPT the period, @, and hyphen.

Leave a Reply