php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42298 preg_match with /u gives different results for \S\S and \S{2}
Submitted: 2007-08-14 16:46 UTC Modified: 2007-09-01 17:54 UTC
From: matthew-php at dracos dot co dot uk Assigned: nlopess (profile)
Status: Closed Package: PCRE related
PHP Version: 5CVS-2007-08-14 (snap) OS: Windows XP
Private report: No CVE-ID: None
 [2007-08-14 16:46 UTC] matthew-php at dracos dot co dot uk
Description:
------------
When using the /u modifier, preg_match, preg_match_all, and preg_replace all give incorrect results using /\S{2}/u but work fine with /\S\S/u which should be equivalent.

Reproduce code:
---------------
$s = "A\xc2\xa3BC";
preg_match_all('/\S\S/u', $s, $m);
print_r($m[0]);
preg_match_all('/\S{2}/u', $s, $m);
print_r($m[0]);


Expected result:
----------------
Array
(
    [0] => A£
    [1] => BC
)
Array
(
    [0] => A£
    [1] => BC
)


Actual result:
--------------
Array
(
    [0] => A£
    [1] => BC
)
Array
(
    [0] => A
    [1] => 
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-15 08:43 UTC] jani@php.net
Assigned to PCRE maintainer.
 [2007-08-15 09:02 UTC] nlopess@php.net
submited upstream: http://bugs.exim.org/580
I will provide more feedback when I end my vacations.
 [2007-09-01 17:54 UTC] nlopess@php.net
bug fixed in PCRE 7.3.
I've upgraded the bundled PCRE package in php 5.2 and 6 branches.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC