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
examples/basic.zigmodified+6-6
Changes to examples/basic.zig
@@ -1,7 +1,7 @@
11const std = ;
22const Regex = .Regex;
33
4pub fn main() !void {
4pub fn main(init: std.process.Init) !void {
55 var gpa = std.heap.GeneralPurposeAllocator(.{}){};
66 defer _ = gpa.deinit();
77 const allocator = gpa.allocator();
@@ -11,7 +11,7 @@ pub fn main() !void {
1111 // Example 1: Simple literal matching
1212 {
1313 std.debug.print("Example 1: Literal matching\n", .{});
14 var regex = try Regex.compile(allocator, "hello");
14 var regex = try Regex.compile(allocator, init.io, "hello");
1515 defer regex.deinit();
1616
1717 const matches = try regex.isMatch("hello");
@@ -22,7 +22,7 @@ pub fn main() !void {
2222 // Example 2: Alternation
2323 {
2424 std.debug.print("Example 2: Alternation (cat|dog)\n", .{});
25 var regex = try Regex.compile(allocator, "cat|dog");
25 var regex = try Regex.compile(allocator, init.io, "cat|dog");
2626 defer regex.deinit();
2727
2828 std.debug.print(" 'cat' matches: {}\n", .{try regex.isMatch("cat")});
@@ -34,7 +34,7 @@ pub fn main() !void {
3434 // Example 3: Star quantifier
3535 {
3636 std.debug.print("Example 3: Star quantifier (a*)\n", .{});
37 var regex = try Regex.compile(allocator, "a*");
37 var regex = try Regex.compile(allocator, init.io, "a*");
3838 defer regex.deinit();
3939
4040 std.debug.print(" '' matches: {}\n", .{try regex.isMatch("")});
@@ -46,7 +46,7 @@ pub fn main() !void {
4646 // Example 4: Finding matches
4747 {
4848 std.debug.print("Example 4: Finding matches\n", .{});
49 var regex = try Regex.compile(allocator, "world");
49 var regex = try Regex.compile(allocator,init.io, "world");
5050 defer regex.deinit();
5151
5252 if (try regex.find("hello world")) |match_result| {
@@ -60,7 +60,7 @@ pub fn main() !void {
6060 // Example 5: Replace
6161 {
6262 std.debug.print("Example 5: Replace\n", .{});
63 var regex = try Regex.compile(allocator, "world");
63 var regex = try Regex.compile(allocator, init.io, "world");
6464 defer regex.deinit();
6565
6666 const result = try regex.replace(allocator, "hello world", "Zig");