Here is the piece of code
var content = @"Script 1 Line 1;
GO
Script 1 Line 2;
GO
";
var regex = new Regex("^GO$", RegexOptions.Multiline);
MatchCollection mc = regex.Matches(content);
Debug.WriteLine(mc.Count);
When I run this code in "dotnetfiddle.com" in Roslyn or Framework 4.7.2 - same result - 2 matches.
When I run this code in the Unit Test project, directly in TestMethod in Framework 4.7.2 - 0 matches
When I run this code in the class method in project compiled targeting netstandard2.0, - 1 match
This is a major headache I need to solve
Additional Test
var sb = new StringBuilder();
sb.AppendLine("Script 1 Line 1;");
sb.AppendLine("GO");
sb.AppendLine("Script 1 Line 2;");
sb.AppendLine("GO");
sb.AppendLine();
var content = sb.ToString();
Console.WriteLine(content);
// ^^^ changed string creation ^^^
var regex = new Regex("^GO$", RegexOptions.Multiline);
MatchCollection mc = regex.Matches(content);
Console.WriteLine(mc.Count);
With this ^^^, even "dotnetfiddle.com" returns 0 matches
I am still not getting the picture here but obviously something about line breaks in different editors. Then why string builder is doing this?