Bug #70304 [Ver->Ana]: Regex not matching on PHP7

From: Date: Thu, 20 Aug 2015 04:34:18 +0000
Subject: Bug #70304 [Ver->Ana]: Regex not matching on PHP7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195365@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
 Updated by:         laruence@php.net
 Reported by:        giggsey at gmail dot com
 Summary:            Regex not matching on PHP7
-Status:             Verified
+Status:             Analyzed
 Type:               Bug
 Package:            PCRE related
 PHP Version:        7.0.0beta3
 Block user comment: N
 Private report:     N

 New Comment:

see also: https://marc.info/?l=php-internals


Previous Comments:
------------------------------------------------------------------------
[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


Thread (7 messages)

« previous php.bugs (#195365) next »