php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72704 mb_ereg & mb_ereg_search do not return named captures
Submitted: 2016-07-29 04:17 UTC Modified: 2018-09-19 06:28 UTC
From: ju1ius at laposte dot net Assigned: nikic (profile)
Status: Closed Package: mbstring related
PHP Version: 5.6.24 OS: Debian Sid
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ju1ius at laposte dot net
New email:
PHP Version: OS:

 

 [2016-07-29 04:17 UTC] ju1ius at laposte dot net
Description:
------------
`mb_ereg`, `mb_ereg_search_regs` & `mb_ereg_search_getregs` return only numbered capturing groups, but they should return both numbered and named capturing groups.

Test script:
---------------
mb_regex_encoding("UTF-8");

mb_ereg('(?<wsp>\s*)(?<word>\w+)', '  中国', $m);
var_dump($m);

mb_ereg_search_init('  中国?');
mb_ereg_search('(?<wsp>\s*)(?<word>\w+)(?<punct>[?!])');
var_dump(mb_ereg_search_getregs());

Expected result:
----------------
array(5) {
  [0]=>
  string(8) "  中国"
  [1]=>
  string(2) "  "
  [2]=>
  string(6) "中国"
  ["wsp"]=>
  string(2) "  "
  ["word"]=>
  string(6) "中国"
}

array(7) {
  [0]=>
  string(11) "  中国?"
  [1]=>
  string(2) "  "
  [2]=>
  string(6) "中国"
  [3]=>
  string(3) "?"
  ["punct"]=>
  string(3) "?"
  ["wsp"]=>
  string(2) "  "
  ["word"]=>
  string(6) "中国"
}

Actual result:
--------------
array(3) {
  [0]=>
  string(8) "  中国"
  [1]=>
  string(2) "  "
  [2]=>
  string(6) "中国"
}

array(4) {
  [0]=>
  string(11) "  中国?"
  [1]=>
  string(2) "  "
  [2]=>
  string(6) "中国"
  [3]=>
  string(3) "?"
}

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-19 06:28 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2018-09-19 06:28 UTC] nikic@php.net
This has been implemented in PHP 7.3 (by yourself ^^) as part of https://github.com/php/php-src/pull/2044, so I'm closing this issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC