php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47656 preg_match doesn't match certain string length
Submitted: 2009-03-14 11:43 UTC Modified: 2009-03-14 13:53 UTC
From: bugs at no-signal dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
 [2009-03-14 11:43 UTC] bugs at no-signal dot com
Description:
------------
preg_match will match against 'ourproducts/documentaries/test12345.html' 
but not against 'ourproducts/documentaries/test123456.html'

preg_match_all does return the expected result, however.

Reproduce code:
---------------
$result = preg_match('#^((?:[^/]+/?)+)/(.*)$#i','ourproducts/documentaries/test123456.html',$matches);

var_dump($matches);

Expected result:
----------------
array(3) {
  [0]=>
  string(40) "ourproducts/documentaries/test123456.html"
  [1]=>
  string(25) "ourproducts/documentaries"
  [2]=>
  string(14) "test123456.html"
}

Actual result:
--------------
array(0) {
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-14 13:53 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

See preg_last_error(), you've hit the backtrack limit due to the way you've written the expression.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 14:01:34 2025 UTC