You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
regex zero-width match starts inside a UTF-8 character #5606
issue: (?!é)(?!$) cannot match at any character boundary in "éé": before either é, (?!é) fails, and at the end, (?!$) fails. Racket instead reports a match at byte offset 1, inside the first é.
The problem here is that matching is always at the byte level internally, and a search for a non-anchored match (i.e., one that doesn't have to start at the beginning of the input) tries byte offsets instead of character offsets of the UTF-8-encoded input.
When given a string input, clearly the search for a match should change to consider offsets that correspond to UTF-8 encodings. For consistency, it should also behave that way when given an input port or byte string to match. I think that change won't affect existing uses of string regexps that are applied to streams that have a mixture of binary data and text, because bad encodings are handled in a way that means a bad encoding will not consume the beginning of a valid encoding.
Edit: "Won't affect" isn't right, because the point would be to change things. I mean that it seems unlikely to affect an existing use of regexps that is working as intended, but I'm not completely certain.
Activity
mflatt commentedon Oct 12, 2026
The problem here is that matching is always at the byte level internally, and a search for a non-anchored match (i.e., one that doesn't have to start at the beginning of the input) tries byte offsets instead of character offsets of the UTF-8-encoded input.
When given a string input, clearly the search for a match should change to consider offsets that correspond to UTF-8 encodings. For consistency, it should also behave that way when given an input port or byte string to match. I think that change won't affect existing uses of string regexps that are applied to streams that have a mixture of binary data and text, because bad encodings are handled in a way that means a bad encoding will not consume the beginning of a valid encoding.
Edit: "Won't affect" isn't right, because the point would be to change things. I mean that it seems unlikely to affect an existing use of regexps that is working as intended, but I'm not completely certain.
regexp: repair match of non-anchored string regexp