php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44623 Inconsistent behaviour by same type of regex
Submitted: 2008-04-03 02:26 UTC Modified: 2008-04-11 01:00 UTC
From: rich dot sapporo at gmail dot com Assigned: fb-req-jani (profile)
Status: No Feedback Package: PCRE related
PHP Version: 5.2.5 OS: Mac OS X 10.5.2
Private report: No CVE-ID: None
 [2008-04-03 02:26 UTC] rich dot sapporo at gmail dot com
Description:
------------
Min/max quantifiers '{}' in preg_match() don't seem to match more than 
765 characters.

Reproduce code:
---------------
// $matches[1] contains the first 765 characters of the string $sample:

preg_match("/^(.{765}).*/", $sample, $matches); 

// doesn't match anything:

preg_match("/^(.{766}).*/", $sample, $matches);

// Values from {0} to {765} appear to work fine.  766 onwards, nothing gets matched.

Expected result:
----------------
I expect the same type of behaviour to happen in both cases.

I realize that preg_match() isn't really necessary to match the first x 
characters in a string, but this problem was affecting a more complex 
regex I was doing.  The "matching the first x chars" example was trying 
to isolate where the problem was occurring.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-03 11:11 UTC] jani@php.net
And how is this _PHP_ bug and not a PCRE bug..? Check with the command line tool 'pcretest' first and compare to version of PCRE lib you've compiled PHP with IF you're not using the bundled one. 
 [2008-04-03 11:25 UTC] rich dot sapporo at gmail dot com
My apologies - in my haste to get to an appointment I didn't check the 
dropdown properly.

Currently using PCRE 7.3 (2007-08-28) - will try 7.6 and see if it goes 
away.
 [2008-04-03 14:14 UTC] jani@php.net
PHP actually has 7.6 bundled (in 5.2.6 :) so you could just get this snapshot and build it using the bundled one:
http://snaps.php.net/php5.2-latest.tar.gz

 [2008-04-11 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 07:01:29 2024 UTC