Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match returns true even though there is extra input #11

Open
dundalek opened this issue Dec 6, 2020 · 0 comments
Open

match returns true even though there is extra input #11

dundalek opened this issue Dec 6, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@dundalek
Copy link

dundalek commented Dec 6, 2020

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
}
@tiehuis tiehuis added the bug Something isn't working label Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants