|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-04-22 15:13 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Type: Bug
+Type: Documentation Problem
-Assigned To:
+Assigned To: cmb
[2021-04-22 15:13 UTC] cmb@php.net
[2021-04-22 15:19 UTC] v dot picture at free dot fr
[2021-04-22 15:28 UTC] cmb@php.net
[2021-04-22 16:37 UTC] v dot picture at free dot fr
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Description: ------------ Hello, The mb_ereg_search_pos function is absolutely not multibyte-safe, it actually returns the position of the match as if the string was not multibyte. The results of this function are exactly the same as if you were using preg_match_all with PREG_OFFSET_CAPTURE, even with the "unicode" flag it's simply NOT working. Test script: --------------- $string = 'jème lé ponés'; mb_ereg_search_init($string, '(?<=[ ^])\w+'); // Detect words while ($pos = mb_ereg_search_pos()) { $match = mb_ereg_search_getregs()[0]; $matchBasedOnPos = mb_substr($string, $pos[0], $pos[1]); if ($matchBasedOnPos !== $match) { throw new \LogicException("Match based on position '{$matchBasedOnPos}' does not correspond to actual match '{$match}'"); } } Expected result: ---------------- No exception thrown Actual result: -------------- LogicException: Match based on position 'é p' does not correspond to actual match 'lé'