2011-06-13 2 views
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"; 

답변

5
string inputString = "Flat---Head-----Self-Tap-Scr---ews----3-x-10mm-8pc"; 
string outputString = Regex.Replace(inputString , @"-+", "-", RegexOptions.None); 
+3

이 질문은 http://stackoverflow.com/questions/5111967/regex-to-remove-a-specific-repeated-character/5112032#5112032와 ​​매우 유사하며, 에. – KeithS

+0

그건 혼란스럽게도 ... – zellio

2

정규식 : -+-로 교체합니다. ;)

관련 문제