note 117231 added to function.mb-ereg
| From: | () | Date: | Wed, 06 May 2015 13:42:21 +0000 |
| Subject: | note 117231 added to function.mb-ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202457@lists.php.net to get a copy of this message | ||
mb_ereg() seems unable to Use "named subpattern".
preg_match() seems a substitute only in UTF-8 encoding.
<?php
$text = 'multi_byte_string';
$pattern = '.*(?<name>string).*'; // "?P" causes "mbregex compile
err" in PHP 5.3.5
if(mb_ereg($pattern, $text, $matches)){
echo '<pre>'.print_r($matches, true).'</pre>';
}else{
echo 'no match';
}
?>
This code ignores "?<name>" in $pattern and displays below.
Array
(
[0] => multi_byte_string
[1] => string
)
$pattern = '/.*(?<name>string).*/u';
if(preg_match($pattern, $text, $matches)){
instead of lines 2 & 3
displays below (in UTF-8 encoding).
Array
(
[0] => multi_byte_string
[name] => string
[1] => string
)
----
Server IP: 49.212.134.217
Probable Submitter: 101.141.38.148
----
Manual Page -- http://php.net/manual/en/function.mb-ereg.php
Edit -- https://master.php.net/note/edit/117231
Del: integrated -- https://master.php.net/note/delete/117231/integrated
Del: useless -- https://master.php.net/note/delete/117231/useless
Del: bad code -- https://master.php.net/note/delete/117231/bad+code
Del: spam -- https://master.php.net/note/delete/117231/spam
Del: non-english -- https://master.php.net/note/delete/117231/non-english
Del: in docs -- https://master.php.net/note/delete/117231/in+docs
Del: other reasons-- https://master.php.net/note/delete/117231
Reject -- https://master.php.net/note/reject/117231
Search -- https://master.php.net/manage/user-notes.php