Monday, December 22, 2008

ASP.NET Regular Expression For Replacing Invalid Characters

ASP.NET Regular Expression For Replacing Invalid Characters

Method 1
Names = Regex.Replace(txtName.Text, "[^A-Za-z0-9]+", "");

Method 2
Names = Regex.Replace(txtName.Text, "[\w", "");


These Regular Expressions can be used for Replacing Invalid Characters in a string.

No comments: