我想找到所有特殊字符的字符串,用连字符替换(-)替换所有特殊字符的字符串在C#
我使用下面的代码
string content = "foo,bar,(regular expression replace) 123";
string pattern = "[^a-zA-Z]"; //regex pattern
string result = System.Text.RegularExpressions.Regex.Replace(content,pattern, "-");
输出
富巴 - 正则表达式替换----
我在输出中出现了多个连字符(---)。
我想获得一些这样的事
富吧,正则表达式替换
如何做到这一点
任何帮助,将不胜感激
谢谢 深度
感谢马克这是工作,但结尾( - ) – Deepu 2009-11-22 14:54:17