#43735 [Opn->Csd]: Bug in mb_ereg_search

From: Date: Fri, 07 Nov 2008 14:27:35 +0000
Subject: #43735 [Opn->Csd]: Bug in mb_ereg_search
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1452@lists.php.net to get a copy of this message
ID: 43735 Updated by: vrana@php.net Reported By: howachen at gmail dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Windows XP PHP Version: 5.2.5 New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. "Defaults to 'ms'." Previous Comments: ------------------------------------------------------------------------ [2008-01-08 15:53:50] felipe@php.net 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 ------------------------------------------------------------------------ [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 (#1452) next »