Voting

: five minus one?
(Example: nine)

The Note You're Voting On

Anonymous
3 years ago
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
)

<< Back to user notes page

To Top