go to bug id or search bugs for
when I use preg_match pattern 0x0, Warning: preg_match(): Null byte in regex
regex has match all character, why php not allow 0x0? it's a bug or has any reason?
I expect preg_match right return 0 or 1 and not warning
Warning: preg_match(): Null byte in regex
Add a Patch
Add a Pull Request
PCRE does not support NUL bytes inside pattern strings.
While not a major pain point, this should probably be documented. The introduction says they can't be delimiters, and the escape sequences page implies it when it mentions non-printing characters, but besides in the actual pcre.org docs linked to with a vague "some limitations" warning, I didn't see anywhere else that conclusively stated it.
PCRE2 supports NUL bytes in patterns, so we may want to lift the
current restriction. OTOH,
already works as expected.
hello email@example.com, I think "/a".chr(0)."bc/" != '/a\\0bc/', so not the same question!
I assume the restriction is purely technical, so if we can lift it with PCRE2 then that's probably the right answer.