also looking at this
Port to latest zig-master
#2
53 files
+1149
-1017
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | const std = ; |
| 2 | 2 | const Regex = .Regex; |
| 3 | 3 | |
| 4 | pub fn main() !void { | |
| 4 | pub fn main(init: std.process.Init) !void { | |
| 5 | 5 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 6 | 6 | defer _ = gpa.deinit(); |
| 7 | 7 | const allocator = gpa.allocator(); |
| @@ -11,7 +11,7 @@ pub fn main() !void { | ||
| 11 | 11 | // Example 1: Simple literal matching |
| 12 | 12 | { |
| 13 | 13 | 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"); | |
| 15 | 15 | defer regex.deinit(); |
| 16 | 16 | |
| 17 | 17 | const matches = try regex.isMatch("hello"); |
| @@ -22,7 +22,7 @@ pub fn main() !void { | ||
| 22 | 22 | // Example 2: Alternation |
| 23 | 23 | { |
| 24 | 24 | 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"); | |
| 26 | 26 | defer regex.deinit(); |
| 27 | 27 | |
| 28 | 28 | std.debug.print(" 'cat' matches: {}\n", .{try regex.isMatch("cat")}); |
| @@ -34,7 +34,7 @@ pub fn main() !void { | ||
| 34 | 34 | // Example 3: Star quantifier |
| 35 | 35 | { |
| 36 | 36 | 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*"); | |
| 38 | 38 | defer regex.deinit(); |
| 39 | 39 | |
| 40 | 40 | std.debug.print(" '' matches: {}\n", .{try regex.isMatch("")}); |
| @@ -46,7 +46,7 @@ pub fn main() !void { | ||
| 46 | 46 | // Example 4: Finding matches |
| 47 | 47 | { |
| 48 | 48 | 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"); | |
| 50 | 50 | defer regex.deinit(); |
| 51 | 51 | |
| 52 | 52 | if (try regex.find("hello world")) |match_result| { |
| @@ -60,7 +60,7 @@ pub fn main() !void { | ||
| 60 | 60 | // Example 5: Replace |
| 61 | 61 | { |
| 62 | 62 | 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"); | |
| 64 | 64 | defer regex.deinit(); |
| 65 | 65 | |
| 66 | 66 | const result = try regex.replace(allocator, "hello world", "Zig"); |