Created
October 2, 2012 13:05
-
-
Save kristofclaes/3818942 to your computer and use it in GitHub Desktop.
Is there a better way to replace multiple dashes with one dash?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string stringToClean = "a-string----with--too-many-------dashes"; | |
while (stringToClean.Contains("--")) | |
{ | |
stringToClean = stringToClean.Replace("--", "-"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Silly me... A simple regex does the trick...