The option IgnorePatternWhiteSpace only applies to the regex processor reading the pattern and not in how it handles the input text. The option allows one to document a pattern by placing items on different lines and allowing for comments using the # escape character. Using the option I can document my regex as follows:


string pattern = @"
^                # Beginning of The Line
(?<Text>[^\d]+)  # Move all non numbers into the Text group.
(?<Number>\d+)   # Get all numbers into the Number Capture group.
";

Otherwise without the option the pattern must be written like this:


string pattern = @"^(?<Text>[^\d]+)(?<Number>\d+)";

Hence the readability for patterns is greatly increased.

Share