php.net |  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: Closed Package: mbstring related
PHP Version: 7.1.16 OS: Windows 7 32-bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jake at qzdesign dot co dot uk
New email:
PHP Version: OS:

 

 [2018-04-20 19:25 UTC] jake at qzdesign dot co dot uk
Description:
------------
The manual page for `mb_ereg_match` at https://secure.php.net/manual/en/function.mb-ereg-match.php 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:
---------------
<?php

// 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-11 10:59 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/7fcb23ea98c75f40553bfcee73b782e62f4e72b4
Log: Fix #76245: mb_ereg_match matches at beginning of subject only
 [2021-11-11 10:59 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 08:01:30 2024 UTC