'Multiline mode in Regex not performing according to documentation
According to the .Net Standard:
The
RegexOptions.Multilineoption, or theminline option, enables the regular expression engine to handle an input string that consists of multiple lines. It changes the interpretation of the^and$language elements so that they match the beginning and end of a line, instead of the beginning and end of the input string.By default,
$matches only the end of the input string. If you specify theRegexOptions.Multilineoption, it matches either the newline character (\n) or the end of the input string.
(emphasis mine)
This seems to say that $ matches the newline character. However this does not seem to be the case. The code:
var m = Regex.Match("123\n456", @"123$", RegexOptions.Multiline);
Console.WriteLine(m.Length);
prints 3, not 4 as would be expected if $ matched newline.
Is this a bug? A documentation error?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
