Skip to content

Instantly share code, notes, and snippets.

@gte445e
Created May 4, 2018 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gte445e/c7838dceb422a5bbe36bfe1176dd9f18 to your computer and use it in GitHub Desktop.
Save gte445e/c7838dceb422a5bbe36bfe1176dd9f18 to your computer and use it in GitHub Desktop.
Trim multiple spaces
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{ 2,}", options);
string input = " 1 2 3 4 5 ";
string result = regex.Replace(input, " ");
Console.WriteLine("<begin>" + result + "<end>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment