Bug #70304 [Com]: Regex not matching on PHP7

From: Date: Thu, 01 Oct 2015 18:40:27 +0000
Subject: Bug #70304 [Com]: Regex not matching on PHP7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196333@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70304&edit=1 ID: 70304 Comment by: giggsey at gmail dot com Reported by: giggsey at gmail dot com Summary: Regex not matching on PHP7 Status: Analyzed Type: Bug Package: PCRE related PHP Version: 7.0.0beta3 Block user comment: N Private report: N New Comment: Is this going to get included/fixed before PHP7 final? Previous Comments: ------------------------------------------------------------------------ [2015-08-26 13:46:49] hzmester at freemail dot hu This is a corner case bug of range optimization in PCRE-JIT. I fixed it. Thank you for reporting it. ------------------------------------------------------------------------ [2015-08-21 01:25:09] cmb@php.net <http://markmail.org/thread/6bcffpbcobyi3ln7>, is not the problem here (otherwise $result would be FALSE). Actually, in this case pcre_exec() returns PCRE_ERROR_NOMATCH (and not PCRE_ERROR_JIT_STACKLIMIT). ------------------------------------------------------------------------ [2015-08-20 04:34:18] laruence@php.net see also: https://marc.info/?l=php-internals ------------------------------------------------------------------------ [2015-08-19 14:42:27] cmb@php.net That is somehow related to the PCRE JIT support. When pcre.jit=0, the behavior is as expected, see <https://3v4l.org/ZkeV6>. ------------------------------------------------------------------------ [2015-08-19 13:22:20] giggsey at gmail dot com Description: ------------ Regex: https://regex101.com/r/aZ7pL6/1 which matches the subject. However, on PHP7 (and HHVM...), the regular expression fails to match anything. If I change the first character matching from '[3-5789]' to '[3-578]', it starts working on PHP7. Demo @ https://3v4l.org/0SMiZ Test script: --------------- <?php $subject = '512345678'; $failingPattern = '/^(?:[3-5789]\d{8})$/x'; $result = preg_match($failingPattern , $subject, $groups, PREG_OFFSET_CAPTURE); var_dump($result, $groups); Expected result: ---------------- int(1) array(1) { [0]=> array(2) { [0]=> string(9) "512345678" [1]=> int(0) } } Actual result: -------------- int(0) array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70304&edit=1

« previous php.bugs (#196333) next »