Hi Folks.
I am not to fermilliar with Reg X and i am tring to remove all none Alpa/Numeric Chars while leaving white spaces. In c#
Here is my code.
string searchString = Regex.Replace(search.Text.Trim().ToLower(), @"[\W]", "");
Response.Redirect(searchString.Replace(" ", "-") + "-search.htm");
I need to put the - Char where there is a space. So ive looked around a bit and i am still stumped. I get that [\s] is all white spaces, but i do not get how to make this an exception to the rule [\W].
I did try string searchString = Regex.Replace(search.Text.Trim().ToLower(), @"[!\s]|[\W]", ""); This was ok but then !"$£ style Chars came through.
And also i tryed string searchString = Regex.Replace(search.Text.Trim().ToLower(), @"[\W]", "", RegexOptions.IgnorePatternWhitespace) but this was wrong as well.
Help....
Thanks Panda.
PS. What dose the @ symbol mean at the start of the pattern, lots of examples ommited this, can i?