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
docs/API.mdmodified+21-0
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -49,6 +49,7 @@ pub const Match = struct { formatting only
4949```
5050
5151**Methods:**
52
5253- `deinit(allocator: std.mem.Allocator)` - Free capture group memory
5354
5455---
Changes to docs/API.md
@@ -64,12 +65,14 @@ pub fn compile(allocator: std.mem.Allocator, pattern: []const u8) !Regex
6465```
6566
6667**Parameters:**
68
6769- `allocator` - Memory allocator for the regex and its internal structures
6870- `pattern` - The regex pattern string
6971
7072**Returns:** `Regex` or error
7173
7274**Errors:**
75
7376- `RegexError.EmptyPattern` - Pattern string is empty
7477- `RegexError.InvalidPattern` - Syntax error in pattern
7578- `RegexError.UnexpectedCharacter` - Invalid character in pattern
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -80,6 +83,7 @@ pub fn compile(allocator: std.mem.Allocator, pattern: []const u8) !Regex formatting only
8083- `RegexError.UnmatchedBracket` - Unbalanced brackets
8184
8285**Example:**
86
8387```zig
8488const allocator = std.heap.page_allocator;
8589var regex = try Regex.compile(allocator, "\\d{3}-\\d{4}");
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -99,6 +103,7 @@ pub fn compileWithFlags( formatting only
99103```
100104
101105**Parameters:**
106
102107- `allocator` - Memory allocator
103108- `pattern` - The regex pattern string
104109- `flags` - Compilation flags (see [Flags](#flags))
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -106,6 +111,7 @@ pub fn compileWithFlags( formatting only
106111**Returns:** `Regex` or error
107112
108113**Example:**
114
109115```zig
110116var regex = try Regex.compileWithFlags(
111117 allocator,
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -124,6 +130,7 @@ pub fn deinit(self: *Regex) void formatting only
124130```
125131
126132**Example:**
133
127134```zig
128135var regex = try Regex.compile(allocator, "pattern");
129136defer regex.deinit(); // Always call deinit when done
Changes to docs/API.md
@@ -142,11 +149,13 @@ pub fn isMatch(self: *const Regex, input: []const u8) !bool
142149```
143150
144151**Parameters:**
152
145153- `input` - The string to search in
146154
147155**Returns:** `true` if match found, `false` otherwise
148156
149157**Example:**
158
150159```zig
151160var regex = try Regex.compile(allocator, "\\d+");
152161defer regex.deinit();
@@ -169,11 +178,13 @@ pub fn find(self: *const Regex, input: []const u8) !?Match
169178```
170179
171180**Parameters:**
181
172182- `input` - The string to search in
173183
174184**Returns:** `Match` if found, `null` otherwise
175185
176186**Example:**
187
177188```zig
178189var regex = try Regex.compile(allocator, "\\d+");
179190defer regex.deinit();
@@ -200,12 +211,14 @@ pub fn findAll(
200211```
201212
202213**Parameters:**
214
203215- `allocator` - Allocator for the results array
204216- `input` - The string to search in
205217
206218**Returns:** Array of `Match` objects (caller owns, must free)
207219
208220**Example:**
221
209222```zig
210223var regex = try Regex.compile(allocator, "\\d+");
211224defer regex.deinit();
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -247,6 +260,7 @@ pub fn replace( formatting only
247260```
248261
249262**Parameters:**
263
250264- `allocator` - Allocator for the result string
251265- `input` - The input string
252266- `replacement` - The replacement string
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -254,6 +268,7 @@ pub fn replace( formatting only
254268**Returns:** New string with first match replaced (caller owns, must free)
255269
256270**Example:**
271
257272```zig
258273var regex = try Regex.compile(allocator, "\\d+");
259274defer regex.deinit();
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -278,6 +293,7 @@ pub fn replaceAll( formatting only
278293```
279294
280295**Parameters:**
296
281297- `allocator` - Allocator for the result string
282298- `input` - The input string
283299- `replacement` - The replacement string
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -285,6 +301,7 @@ pub fn replaceAll( formatting only
285301**Returns:** New string with all matches replaced (caller owns, must free)
286302
287303**Example:**
304
288305```zig
289306var regex = try Regex.compile(allocator, "\\d+");
290307defer regex.deinit();
Changes to docs/API.md
@@ -312,12 +329,14 @@ pub fn split(
312329```
313330
314331**Parameters:**
332
315333- `allocator` - Allocator for the results array
316334- `input` - The string to split
317335
318336**Returns:** Array of string slices (caller owns array, must free)
319337
320338**Example:**
339
321340```zig
322341var regex = try Regex.compile(allocator, ",");
323342defer regex.deinit();
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -357,6 +376,7 @@ pub const CompileFlags = packed struct { formatting only
357376When `true`, the pattern matches both uppercase and lowercase letters.
358377
359378**Example:**
379
360380```zig
361381var regex = try Regex.compileWithFlags(
362382 allocator,
formatting only · 7 hidden lines
Changes to docs/API.md
@@ -397,6 +417,7 @@ pub const RegexError = error{ formatting only
397417```
398418
399419**Error Handling Example:**
420
400421```zig
401422const regex = Regex.compile(allocator, "[invalid") catch |err| {
402423 switch (err) {