Hi,
I would like to find all special characters in a string and replace with a Hyphen (-)
I am using the below code
string content = "foo,bar,(regular expression replace) 123";
string pattern = "[^a-zA-Z]"; //regex pattern
string result = System.Text.RegularExpressions.Regex.Replace(content,pattern, "-");
OutPut
foo-bar--regular-expression-replace----
I am getting multiple occurrence of hyphen (---) in the out put.
I would like to get some thing like this
foo-bar-regular-expression-replace
How do I achieve this
Any help would be appreciated
Thanks Deepu