2
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 = "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);
正則表達式:-+
,更換-
。 ;)
這個問題是非常相似的http://stackoverflow.com/questions/5111967/regex-to-remove-a-specific-repeated-character/5112032#5112032,這是答案,上。 – KeithS 2011-06-13 15:31:09
這令人不安... – zellio 2011-06-13 15:32:15