php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #43735 Bug in mb_ereg_search
Submitted: 2008-01-03 09:07 UTC Modified: 2008-11-07 14:27 UTC
From: howachen at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: howachen at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-03 09:07 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-08 15:53 UTC] 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-11-07 14:27 UTC] vrana@php.net
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'."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Sep 08 06:00:01 2025 UTC