|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76245 mb_ereg_match matches at beginning of subject only
Submitted: 2018-04-20 19:25 UTC Modified: -
From: jake at qzdesign dot co dot uk Assigned:
Status: Open Package: mbstring related
PHP Version: 7.1.16 OS: Windows 7 32-bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
47 + 43 = ?
Subscribe to this entry?

 [2018-04-20 19:25 UTC] jake at qzdesign dot co dot uk
The manual page for `mb_ereg_match` at makes no mention that `$pattern` is only matched at the beginning of `$string` (i.e. it includes an implied `^` at the start).

It is mentioned in a user contributed note, but this behaviour really should be included in the main documentation, probably in a highlighted "Note" or "Warning" box, as it is very important for using the function, and the behaviour would be unexpected as most other similar functions in both PHP and other languages do not behave this way.

(It may be a bug in the function and it is not supposed to behave this way, but for compatibility reasons it probably can't be fixed until a major release.)

Test script:

// note space at start of $string parameter
echo mb_ereg_match('[[:alpha:]]', ' a') ? 'matched' : 'not matched';

Expected result:
Based on the documentation as it is, I expected "matched" to be output.

I expect to be able to easily determine what this simple script would output from the documantation.

Actual result:
"not matched" is output, but the documentation makes no indication that this would be the case.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 26 13:03:37 2021 UTC