zig-regex
zig-regex copied to clipboard
match returns true even though there is extra input
See the example, when using regex for validation I would expect .match
to match on the whole input, but it returns true even if there is extra input.
Running Zig 0.7.0 and zig-regex from master:
const std = @import("std");
const print = std.debug.print;
const Regex = @import("zig-regex/src/regex.zig").Regex;
pub fn main() !void {
var re1 = try Regex.compile(std.heap.page_allocator, "ab");
print("{}\n", .{try re1.match("ab")}); // true, ok
print("{}\n", .{try re1.match("abc")}); // Expected: false, Actual: true
var re2 = try Regex.compile(std.heap.page_allocator, "^ab$");
print("{}\n", .{try re2.match("ab")}); // true, ok
print("{}\n", .{try re2.match("abc")}); // Expected: false, Actual: true
}