Simple method to replace all the special characters
with underscore or space.
Here is the code, while inserting data you can
replace characters with this code step.
cmd.Parameters.AddWithValue("@column_name", Regex.Replace(txt_hedng.Text,
"[^a-zA-Z0-9]+", "_"));
Another Example
string quote =
"being #cool is so difficult !!";
string replace = Regex.Replace(quote, "[^a-zA-Z0-9_]+", " ");
Output
being cool is so difficult
Comments
Post a Comment