Goto(NoStartingPositionFound);
}
writer.WriteLine("pos = newlinePos + pos + 1;");
+
+ // We've updated the position. Make sure there's still enough room in the input for a possible match.
+ using (EmitBlock(writer, minRequiredLength switch
+ {
+ 0 => "if (pos > inputSpan.Length)",
+ 1 => "if (pos >= inputSpan.Length)",
+ _ => $"if (pos > inputSpan.Length - {minRequiredLength})"
+ }))
+ {
+ Goto(NoStartingPositionFound);
+ }
}
writer.WriteLine();
break;
Ldc(1);
Add();
Stloc(pos);
+
+ // We've updated the position. Make sure there's still enough room in the input for a possible match.
+ // if (pos > inputSpan.Length - minRequiredLength) returnFalse;
+ Ldloca(inputSpan);
+ Call(s_spanGetLengthMethod);
+ if (minRequiredLength != 0)
+ {
+ Ldc(minRequiredLength);
+ Sub();
+ }
+ Ldloc(pos);
+ BltFar(returnFalse);
}
MarkLabel(label);
}
};
- // Using ^ with multiline
+ // Using ^ and $ with multiline
yield return new object[]
{
engine,
}
};
+ yield return new object[]
+ {
+ engine,
+ @"^[^a]a", "bar\n", RegexOptions.Multiline,
+ new[]
+ {
+ new CaptureData("ba", 0, 2)
+ }
+ };
+
+ yield return new object[]
+ {
+ engine,
+ @"^[^a]a", "car\nbar\n", RegexOptions.Multiline,
+ new[]
+ {
+ new CaptureData("ca", 0, 2),
+ new CaptureData("ba", 4, 2)
+ }
+ };
+
+ yield return new object[]
+ {
+ engine,
+ @"[0-9]cat$", "1cat\n2cat", RegexOptions.Multiline,
+ new[]
+ {
+ new CaptureData("1cat", 0, 4),
+ new CaptureData("2cat", 5, 4)
+ }
+ };
+
if (!PlatformDetection.IsNetFramework)
{
// .NET Framework missing fix in https://github.com/dotnet/runtime/pull/1075