#43735 [Opn]: Bug in mb_ereg_search

From: Date: Tue, 08 Jan 2008 15:53:50 +0000
Subject: #43735 [Opn]: Bug in mb_ereg_search
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-425@lists.php.net to get a copy of this message
ID: 43735 Updated by: felipe@php.net Reported By: howachen at gmail dot com Status: Open -Bug Type: Regexps related +Bug Type: Documentation problem Operating System: Windows XP PHP Version: 5.2.5 New Comment: Using the default option (ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE, i.e. 'sm' or 'p') or 's' it no matches, as you expect. Examples: <?php $str = " <div>apple\n </div> \n abc "; $pattern = '^\s*<div>[\w\W]*?</div>\s*$'; var_dump(mb_ereg_match($pattern, $str, 'p')); var_dump(mb_ereg_match($pattern, $str, 's')); var_dump(mb_ereg_match($pattern, $str, 'si')); var_dump(mb_ereg_match($pattern, $str, 'm')); var_dump(mb_ereg_match($pattern, $str, 'mi')); ?> oniguruma/doc/API says: ONIG_OPTION_SINGLELINE: '^' -> '\A', '$' -> '\z', '\Z' -> '\z' Although, IMHO, SINGLELINE was confused with MULTILINE in this extension. pcre.org/man.txt: \Z - matches at the end of the subject also matches before a newline at the end of the subject \z - matches only at the end of the subject Reclassified -> Doc. problem Previous Comments: ------------------------------------------------------------------------ [2008-01-03 09:07:21] howachen at gmail dot com Description: ------------ The mb_ereg_search() is regarding $ as end of line rather than end of string. Reproduce code: --------------- <?php $str = " <div>apple\n </div> \n abc "; $pattern = "^\s*<div>[\w\W]*?</div>\s*$"; print $str ; mb_ereg_search_init($str, $pattern, "i"); if ( mb_ereg_search() ) { $r = mb_ereg_search_getregs(); print_r($r); do { $cnt++; $r = mb_ereg_search_regs(); } while($r); } ?> Expected result: ---------------- Nothing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43735&edit=1

« previous php.doc.bugs (#425) next »