PHPackages                             zendtech/polyfill-mb-ereg - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zendtech/polyfill-mb-ereg

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zendtech/polyfill-mb-ereg
=========================

Polyfill for mb\_ereg(), mb\_eregi(), mb\_ereg\_match(), and mb\_ereg\_replace\*() functions; primary use case is for mbstring on Windows 7.4+

1.0.0(4y ago)34.0k↓25%1BSD-3-ClausePHPPHP ^5.6 || ^7.0 || ^8.0

Since Aug 6Pushed 4y ago3 watchersCompare

[ Source](https://github.com/zendtech/polyfill-mb-ereg)[ Packagist](https://packagist.org/packages/zendtech/polyfill-mb-ereg)[ Docs](https://github.com/zendtech/polyfill-mb-ereg)[ RSS](/packages/zendtech-polyfill-mb-ereg/feed)WikiDiscussions 1.0.x Synced 2d ago

READMEChangelogDependencies (3)Versions (2)Used By (1)

zendtech/polyfill-mb-ereg - mb\_ereg polyfill
=============================================

[](#zendtechpolyfill-mb-ereg---mb_ereg-polyfill)

Installation
------------

[](#installation)

```
composer require zendtech/polyfill-mb-ereg
```

Usage
-----

[](#usage)

This package provides polyfills for the following functions

- mb\_ereg
- mb\_eregi
- mb\_ereg\_match
- mb\_ereg\_replace
- mb\_ereg\_replace\_callback
- mb\_eregi\_replace
- mb\_regex\_encoding
- mb\_regex\_set\_options

It can safely be used alongside [symfony/polyfill-mbstring](https://symfony.com/components/Polyfill%20Mbstring), as that polyfill does not provide polyfills for the ereg functions.

The main reason to use this package is if:

- You are using PHP on Windows
- You are using PHP 7.4+ on that platform
- And libraries you use use mb\_ereg functionality

Starting with PHP 7.4, php.net stopped shipping the oniguruma library on which the mbstring extension is based, in favor of using system packages. Microsoft started building its PHP packages against libmbfl instead, as it is a roughly equivalent library for Windows. Unfortunately, that library does not expose the ereg functionality, which means that any PHP binaries built against it do not have this functionality present.

In most cases, switching to PCRE functionality is preferred, as it can match many multibyte sequences out-of-the-box, particularly when using the `u` PCRE flag with your pattern. However, when using third party packages, you may not be able to control whether or not PCRE is used — and hence the reason for this package.

Caveats
-------

[](#caveats)

Please note the following caveats and behavior differences for this polyfill.

- This package DOES NOT provide polyfills for any of the `mb_ereg_search` family of functions, as these are not often used, and rely on global state and pointers that are brittle even under the native extension.
- The polyfill for `mb_ereg()`:

    - Always returns a boolean. In PHP versions prior to PHP 8, the native extension would return the number of bytes matched, or, if the length of the match was zero, the integer 1. Since the typical use case for the function is for boolean testing, the polyfill returns a boolean always.
    - Always sets `$matches`, if passed, to an array, even if no matches were made. This has been the behavior since PHP 7.1, and it did not make sense to vary the behavior for PHP 5.6.
- The polyfill DOES NOT support named backrefs of the form `\k''` or `\k` in replacements provided to `mb_ereg_replace()`, `mb_eregi_replace()`, or `mb_ereg_replace_callback()`. This is due to the fact that the PCRE engine included in PHP does not support them.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1792d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25943?v=4)[Matthew Weier O'Phinney](/maintainers/weierophinney)[@weierophinney](https://github.com/weierophinney)

---

Top Contributors

[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (2 commits)")

---

Tags

mbstringpolyfillzend

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zendtech-polyfill-mb-ereg/health.svg)

```
[![Health](https://phpackages.com/badges/zendtech-polyfill-mb-ereg/health.svg)](https://phpackages.com/packages/zendtech-polyfill-mb-ereg)
```

###  Alternatives

[symfony/polyfill-mbstring

Symfony polyfill for the Mbstring extension

7.8k1.2B759](/packages/symfony-polyfill-mbstring)[paragonie/random_compat

PHP 5.x polyfill for random\_bytes() and random\_int() from PHP 7

8.2k686.9M434](/packages/paragonie-random-compat)[symfony/polyfill-ctype

Symfony polyfill for ctype functions

4.0k1.0B192](/packages/symfony-polyfill-ctype)[symfony/polyfill-php72

Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions

4.7k688.6M35](/packages/symfony-polyfill-php72)[symfony/polyfill-intl-idn

Symfony polyfill for intl's idn\_to\_ascii and idn\_to\_utf8 functions

3.4k823.1M147](/packages/symfony-polyfill-intl-idn)[symfony/polyfill-intl-normalizer

Symfony polyfill for intl's Normalizer class and related functions

2.1k885.3M65](/packages/symfony-polyfill-intl-normalizer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
