Doc #77726 [Com]: PCRE does not support NULs in patterns; PHP will warn

From: Date: Wed, 13 Mar 2019 04:16:13 +0000
Subject: Doc #77726 [Com]: PCRE does not support NULs in patterns; PHP will warn
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16475@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77726&edit=1 ID: 77726 Comment by: 605036592 at qq dot com Reported by: 605036592 at qq dot com Summary: PCRE does not support NULs in patterns; PHP will warn Status: Open Type: Documentation Problem Package: PCRE related Operating System: CentOS-7.4-x86_64 PHP Version: 7.2.16 Block user comment: N Private report: N New Comment: hello cmb@php.net, I think "/a".chr(0)."bc/" != '/a\\0bc/', so not the same question! Previous Comments: ------------------------------------------------------------------------ [2019-03-12 17:22:17] cmb@php.net PCRE2 supports NUL bytes in patterns, so we may want to lift the current restriction. OTOH, preg_match('/a\\0bc/', 'abc') already works as expected. ------------------------------------------------------------------------ [2019-03-12 08:15:21] requinix@php.net 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. ------------------------------------------------------------------------ [2019-03-12 07:42:53] 605036592 at qq dot com Description: ------------ 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? Test script: --------------- preg_match("/a".chr(0)."bc/", 'abc'); Expected result: ---------------- I expect preg_match right return 0 or 1 and not warning Actual result: -------------- Warning: preg_match(): Null byte in regex ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77726&edit=1

« previous php.doc.bugs (#16475) next »