|  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
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: matthew-php at dracos dot co dot uk
New email:
PHP Version: OS:


 [2007-08-14 16:46 UTC] matthew-php at dracos dot co dot uk
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);
preg_match_all('/\S{2}/u', $s, $m);

Expected result:
    [0] => A£
    [1] => BC
    [0] => A£
    [1] => BC

Actual result:
    [0] => A£
    [1] => BC
    [0] => A
    [1] => 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-15 08:43 UTC]
Assigned to PCRE maintainer.
 [2007-08-15 09:02 UTC]
submited upstream:
I will provide more feedback when I end my vacations.
 [2007-09-01 17:54 UTC]
bug fixed in PCRE 7.3.
I've upgraded the bundled PCRE package in php 5.2 and 6 branches.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Jan 29 14:03:43 2023 UTC