What’s happening in this code snippet ?
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{2,}", options);
string outStr = regex.Replace(inStr, @" ");
What I am looking for is to replace any sequences of “white” spaces ( including TAB, CR, LF ) with a single space.
Let’s break it down:
So this would match 2 or more consecutive spaces.
Then the .Replace call, this would replace those sequences of 2 or more spaces with just one space.