ReviewOS

also looking at this

zig-utils/zig-regex

Port to latest zig-master

#2
Closed armagidon-exception wants to merge main into main
53 files +1149 -1017
tests/named_captures.zigmodified+12-12
Changes to tests/named_captures.zig
@@ -5,7 +5,7 @@ const Regex = @import("regex").Regex;
55
66test "named group: Python style (?P<name>...)" {
77 const allocator = std.testing.allocator;
8 var regex = try Regex.compile(allocator, "(?P<word>\\w+)");
8 var regex = try Regex.compile(allocator, std.testing.io, "(?P<word>\\w+)");
99 defer regex.deinit();
1010
1111 if (try regex.find("hello")) |match| {
@@ -33,7 +33,7 @@ test "named group: Python style (?P<name>...)" {
3333
3434test "named group: .NET/Perl style (?<name>...)" {
3535 const allocator = std.testing.allocator;
36 var regex = try Regex.compile(allocator, "(?<digit>\\d+)");
36 var regex = try Regex.compile(allocator, std.testing.io, "(?<digit>\\d+)");
3737 defer regex.deinit();
3838
3939 if (try regex.find("123")) |match| {
@@ -52,7 +52,7 @@ test "named group: .NET/Perl style (?<name>...)" {
5252
5353test "named group: multiple named groups" {
5454 const allocator = std.testing.allocator;
55 var regex = try Regex.compile(allocator, "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})");
55 var regex = try Regex.compile(allocator, std.testing.io, "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})");
5656 defer regex.deinit();
5757
5858 if (try regex.find("2025-10-27")) |match| {
@@ -79,7 +79,7 @@ test "named group: multiple named groups" {
7979
8080test "named group: mixed with numbered groups" {
8181 const allocator = std.testing.allocator;
82 var regex = try Regex.compile(allocator, "(\\w+)@(?P<domain>\\w+\\.\\w+)");
82 var regex = try Regex.compile(allocator, std.testing.io, "(\\w+)@(?P<domain>\\w+\\.\\w+)");
8383 defer regex.deinit();
8484
8585 if (try regex.find("user@example.com")) |match| {
@@ -100,7 +100,7 @@ test "named group: mixed with numbered groups" {
100100
101101test "named group: non-existent name returns null" {
102102 const allocator = std.testing.allocator;
103 var regex = try Regex.compile(allocator, "(?P<word>\\w+)");
103 var regex = try Regex.compile(allocator, std.testing.io, "(?P<word>\\w+)");
104104 defer regex.deinit();
105105
106106 if (try regex.find("hello")) |match| {
@@ -119,7 +119,7 @@ test "named group: non-existent name returns null" {
119119
120120test "named group: with alternation" {
121121 const allocator = std.testing.allocator;
122 var regex = try Regex.compile(allocator, "(?P<protocol>http|https)://(?P<host>[^/]+)");
122 var regex = try Regex.compile(allocator, std.testing.io, "(?P<protocol>http|https)://(?P<host>[^/]+)");
123123 defer regex.deinit();
124124
125125 if (try regex.find("https://example.com")) |match| {
@@ -141,7 +141,7 @@ test "named group: with alternation" {
141141
142142test "named group: with quantifiers" {
143143 const allocator = std.testing.allocator;
144 var regex = try Regex.compile(allocator, "(?P<tag><[^>]+>)(?P<content>.*)");
144 var regex = try Regex.compile(allocator, std.testing.io, "(?P<tag><[^>]+>)(?P<content>.*)");
145145 defer regex.deinit();
146146
147147 if (try regex.find("<div>hello world</div>")) |match| {
@@ -163,7 +163,7 @@ test "named group: with quantifiers" {
163163
164164test "named group: nested groups" {
165165 const allocator = std.testing.allocator;
166 var regex = try Regex.compile(allocator, "(?P<outer>(inner))");
166 var regex = try Regex.compile(allocator, std.testing.io, "(?P<outer>(inner))");
167167 defer regex.deinit();
168168
169169 if (try regex.find("inner")) |match| {
@@ -186,7 +186,7 @@ test "named group: nested groups" {
186186
187187test "named group: with non-capturing group" {
188188 const allocator = std.testing.allocator;
189 var regex = try Regex.compile(allocator, "(?:prefix-)?(?P<name>\\w+)");
189 var regex = try Regex.compile(allocator, std.testing.io, "(?:prefix-)?(?P<name>\\w+)");
190190 defer regex.deinit();
191191
192192 if (try regex.find("prefix-test")) |match| {
@@ -206,7 +206,7 @@ test "named group: with non-capturing group" {
206206
207207test "named group: email parser example" {
208208 const allocator = std.testing.allocator;
209 var regex = try Regex.compile(allocator, "(?P<user>[^@]+)@(?P<domain>[^@]+)");
209 var regex = try Regex.compile(allocator, std.testing.io, "(?P<user>[^@]+)@(?P<domain>[^@]+)");
210210 defer regex.deinit();
211211
212212 if (try regex.find("john.doe@example.com")) |match| {
@@ -228,7 +228,7 @@ test "named group: email parser example" {
228228
229229test "named group: IP address parser" {
230230 const allocator = std.testing.allocator;
231 var regex = try Regex.compile(allocator, "(?P<a>\\d+)\\.(?P<b>\\d+)\\.(?P<c>\\d+)\\.(?P<d>\\d+)");
231 var regex = try Regex.compile(allocator, std.testing.io, "(?P<a>\\d+)\\.(?P<b>\\d+)\\.(?P<c>\\d+)\\.(?P<d>\\d+)");
232232 defer regex.deinit();
233233
234234 if (try regex.find("192.168.1.1")) |match| {
@@ -256,7 +256,7 @@ test "named group: IP address parser" {
256256
257257test "named group: findAll preserves names" {
258258 const allocator = std.testing.allocator;
259 var regex = try Regex.compile(allocator, "(?P<num>\\d+)");
259 var regex = try Regex.compile(allocator, std.testing.io, "(?P<num>\\d+)");
260260 defer regex.deinit();
261261
262262 var matches = try regex.findAll(allocator, "123 456 789");