.Net regex matching $ with the end of the string and not of line, even with multiline enabled
I'm trying to highlight markdown code, but am running into this weird behavior of the .NET regex multiline option. The following expression: ^(#+).+$ works fine on any online regex testing tool: But it refuses to work with .net: It doesn't seem to take into account the $ tag, and just highlights everything until the end of the string, no matter what. This is my C# RegExpression = new Regex(@"^(#+).+$", RegexOptions.Multiline) What am I missing? It is clear your text contains a linebreak other than LF. In .NET regex, a dot matches any char but LF (a newline char, \n ). See Multiline Mode MSDN