note 123724 added to function.mb-ereg-match

From: Date: Sun, 24 Mar 2019 18:47:53 +0000
Subject: note 123724 added to function.mb-ereg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-210454@lists.php.net to get a copy of this message
It took me a while to discover that you must escape characters like parentheses (), square brackets [] and ^ (and maybe more) if you want to match these as a literal. Otherwise you may get some erratic outcome. In summary, using a match anywhere in the string as an example: <?php $needle = "["; $haystack = "some_array[]"; $test= mb_ereg_match(".*".$needle, $haystack); // returns false and a php warning $test= mb_ereg_match('.*'.preg_quote($needle), $haystack); // returns true ?> ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.194 (proxied: 217.103.108.113) ---- Manual Page -- http://php.net/manual/en/function.mb-ereg-match.php Edit -- https://master.php.net/note/edit/123724 Del: integrated -- https://master.php.net/note/delete/123724/integrated Del: useless -- https://master.php.net/note/delete/123724/useless Del: bad code -- https://master.php.net/note/delete/123724/bad+code Del: spam -- https://master.php.net/note/delete/123724/spam Del: non-english -- https://master.php.net/note/delete/123724/non-english Del: in docs -- https://master.php.net/note/delete/123724/in+docs Del: other reasons-- https://master.php.net/note/delete/123724 Reject -- https://master.php.net/note/reject/123724 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#210454) next »