Skip to content

Commit 8a04343

Browse files
committedMay 31, 2024·
PCRE_NO_AUTO_CAPTURE n
1 parent 8058d95 commit 8a04343

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎src/Peachpie.Library.RegularExpressions/RegexOptions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ public enum RegexOptions
5353
/// <summary>
5454
/// Disables the use of numbered capturing parentheses in the pattern.
5555
/// </summary>
56-
PCRE2_NO_AUTO_CAPTURE = 0x20000, // n
56+
PCRE2_NO_AUTO_CAPTURE = ExplicitCapture, // n
5757

5858
///// <summary>
5959
///// Evaluate as PHP code.
6060
///// Deprecated and removed.
6161
///// </summary>
62-
//PREG_REPLACE_EVAL = 0x40000, // e
62+
//PREG_REPLACE_EVAL = 0x20000, // e
6363

6464
//
6565
// PCRE options for newline handling

‎tests/Peachpie.Library.RegularExpressions.Tests/PcreTests.cs

+13
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ public void Test3()
4242
Assert.True(match("/^[0-2]?[0-9]:[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,6})?)?$/", "22:00").Success);
4343
}
4444

45+
[Fact]
46+
public void TestNoAutoCapture()
47+
{
48+
var m1 = match("/(?:a|b)c(?:d|e)/", "ace"); // groups 0
49+
var m2 = match("/(a|b)c(d|e)/n", "ace"); // groups 0
50+
var m3 = match("/(a|b)c(d|e)/", "ace"); // groups 0,1,2
51+
52+
Assert.Equal(m1.PcreGroups.Count, m2.PcreGroups.Count);
53+
Assert.True(m3.PcreGroups.Count > m2.PcreGroups.Count);
54+
//Assert.(1, m2.PcreGroups.Count);
55+
}
56+
57+
4558
[Fact]
4659
public void TestHexDigits()
4760
{

0 commit comments

Comments
 (0)
Please sign in to comment.