|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70304 Regex not matching on PHP7
Submitted: 2015-08-19 13:22 UTC Modified: 2016-07-20 23:01 UTC
Avg. Score:4.0 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: giggsey at gmail dot com Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: 7.0.0beta3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: giggsey at gmail dot com
New email:
PHP Version: OS:


 [2015-08-19 13:22 UTC] giggsey at gmail dot com
Regex: 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 @

Test script:

$subject = '512345678';

$failingPattern = '/^(?:[3-5789]\d{8})$/x';

$result = preg_match($failingPattern , $subject, $groups, PREG_OFFSET_CAPTURE);

var_dump($result, $groups);

Expected result:
array(1) {
  array(2) {
    string(9) "512345678"

Actual result:
array(0) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-19 14:42 UTC]
-Status: Open +Status: Verified
 [2015-08-19 14:42 UTC]
That is somehow related to the PCRE JIT support. When pcre.jit=0,
the behavior is as expected, see <>.
 [2015-08-20 04:34 UTC]
-Status: Verified +Status: Analyzed
 [2015-08-20 04:34 UTC]
see also:
 [2015-08-21 01:25 UTC]
<>, is not the problem
here (otherwise $result would be FALSE). Actually, in this case
pcre_exec() returns PCRE_ERROR_NOMATCH (and not
 [2015-08-26 13:46 UTC] 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-10-01 18:40 UTC] giggsey at gmail dot com
Is this going to get included/fixed before PHP7 final?
 [2016-07-20 23:01 UTC]
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-07-20 23:01 UTC]
For the record: this bug has been fixed as of libpcre 8.38 (and
therefore as of PHP 7.0.3), see <>.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 25 22:03:39 2021 UTC