note 126307 added to function.mb-ereg
| From: | Anonymous at main dot php dot net | Date: | Tue, 03 Aug 2021 19:56:38 +0000 |
| Subject: | note 126307 added to function.mb-ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216738@lists.php.net to get a copy of this message | ||
mb_ereg() with a named-subpattern
never catches non-named-subpattern.
(Oniguruma's restriction)
<?php
$str = 'abcdefg';
$patternA = '\A(abcd)(.*)\z'; // both caught [1]abcd [2]efg
$patternB = '\A(abcd)(?<rest>.*)\z'; // non-named 'abcd' never caught
mb_ereg($patternA, $str, $match);
echo '<pre>'.print_r($match, true).'</pre>';
mb_ereg($patternB, $str, $match);
echo '<pre>'.print_r($match, true).'</pre>';
?>
Array
(
[0] => abcdefg
[1] => abcd
[2] => efg
)
Array
(
[0] => abcdefg
[1] => efg
[rest] => efg
)
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 222.149.96.159)
----
Manual Page -- https://php.net/manual/en/function.mb-ereg.php
Edit -- https://main.php.net/note/edit/126307
Del: integrated -- https://main.php.net/note/delete/126307/integrated
Del: useless -- https://main.php.net/note/delete/126307/useless
Del: bad code -- https://main.php.net/note/delete/126307/bad+code
Del: spam -- https://main.php.net/note/delete/126307/spam
Del: non-english -- https://main.php.net/note/delete/126307/non-english
Del: in docs -- https://main.php.net/note/delete/126307/in+docs
Del: other reasons-- https://main.php.net/note/delete/126307
Reject -- https://main.php.net/note/reject/126307
Search -- https://main.php.net/manage/user-notes.php