问题描述
|
string inputString = \"Flat---Head-----Self-Tap-Scr---ews----3-x-10mm-8pc\";
string outputString = \"Flat-Head-Self-Tap-Scr-ews-3-x-10mm-8pc\";
解决方法
string inputString = \"Flat---Head-----Self-Tap-Scr---ews----3-x-10mm-8pc\";
string outputString = Regex.Replace(inputString,@\"-+\",\"-\",RegexOptions.None);
, 正则表达式:-+
,替换为-
。 ;)