php / php/doc-en

mbregex missing documentation about supported RE syntax

Open
#2,024 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Extension: mbstring
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Description

The following code:

<?php
mb_ereg_search_init("qaaoiuu");
mb_ereg_search_setpos(1);
var_dump(mb_ereg_search_pos("^a{2}(..)u{2}"));

Resulted in this output:

bool(false)

But I expected this output instead:

array(2) {
  [0]=>
  int(1)
  [1]=>
  int(6)
}

The "^" modifier is not applying to the start of the whole string either (independently of "setpos"), as :

<?php
mb_ereg_search_init("aaoiuu");
mb_ereg_search_setpos(1);
var_dump(mb_ereg_search_pos("^a{2}(..)u{2}"));

Returns false too (this should be expected).

bool(false)

Does "^" have a different meaning in the mb_ereg_search functions?

PHP Version

PHP 8.1.12 and previous versions

Operating System

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the mb_ereg_search functions and the documented regular-expression syntax, then reproduce the examples using PHP 8.1. Document the meaning of ^ when searching with mb_ereg_search and clarify the supported syntax so the reported behavior is explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.