PHPackages                             anhoder/boyer-moore - 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. anhoder/boyer-moore

ActiveLibrary

anhoder/boyer-moore
===================

Boyer-Moore algorithm in PHP(support Chinese).

0.1.1(4y ago)1211MITPHP

Since Sep 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/anhoder/boyer-moore)[ Packagist](https://packagist.org/packages/anhoder/boyer-moore)[ RSS](/packages/anhoder-boyer-moore/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

PHP实现的Boyer-Moore字符搜索算法，支持中文。 PHP implementation of Boyer-Moore character search algorithm, support for Chinese.

[![GitHub repo size](https://camo.githubusercontent.com/8d16c58c52f2d7d9e176bab7d143d5abfdab4912ca4a0b4978c100a712c8db46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f616e686f6465722f626f7965722d6d6f6f7265)](https://camo.githubusercontent.com/8d16c58c52f2d7d9e176bab7d143d5abfdab4912ca4a0b4978c100a712c8db46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f616e686f6465722f626f7965722d6d6f6f7265) [![GitHub](https://camo.githubusercontent.com/929b55f1d9999ebcde3dd2376aa5f455c78a44592b37c6b53db4415b7fe82927/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616e686f6465722f626f7965722d6d6f6f7265)](https://camo.githubusercontent.com/929b55f1d9999ebcde3dd2376aa5f455c78a44592b37c6b53db4415b7fe82927/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616e686f6465722f626f7965722d6d6f6f7265) [![Last Tag](https://camo.githubusercontent.com/ceb6d417efbf6e4aaa1f4c1debd0a16ed1168d3b0cb9ca1734498e0f2c6ad05d/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f616e686f6465722f626f7965722d6d6f6f7265)](https://camo.githubusercontent.com/ceb6d417efbf6e4aaa1f4c1debd0a16ed1168d3b0cb9ca1734498e0f2c6ad05d/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f616e686f6465722f626f7965722d6d6f6f7265) [![GitHub last commit](https://camo.githubusercontent.com/b365badf53090f29e3615828bc2bac68b82035435fa52672d00a42f91de4862c/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6173742d636f6d6d69742f616e686f6465722f626f7965722d6d6f6f7265)](https://camo.githubusercontent.com/b365badf53090f29e3615828bc2bac68b82035435fa52672d00a42f91de4862c/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6173742d636f6d6d69742f616e686f6465722f626f7965722d6d6f6f7265) [![GitHub All Releases](https://camo.githubusercontent.com/6b13cb529dc245b883a73b48d39df4a3bd3057e0b43cc0bb7d8dda7712ae3e23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f616e686f6465722f626f7965722d6d6f6f72652f746f74616c)](https://camo.githubusercontent.com/6b13cb529dc245b883a73b48d39df4a3bd3057e0b43cc0bb7d8dda7712ae3e23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f616e686f6465722f626f7965722d6d6f6f72652f746f74616c)

[![GitHub stars](https://camo.githubusercontent.com/48268db9323daca17cb6b41377a8b7a4d9ff0c2d8c69173bf85b86280d879ef9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f616e686f6465722f626f7965722d6d6f6f72653f7374796c653d736f6369616c)](https://camo.githubusercontent.com/48268db9323daca17cb6b41377a8b7a4d9ff0c2d8c69173bf85b86280d879ef9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f616e686f6465722f626f7965722d6d6f6f72653f7374796c653d736f6369616c) [![GitHub forks](https://camo.githubusercontent.com/edf7a7a703e796c6100c8b1ced00304fa595827ae91374b47edc5b40139d8ff6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f616e686f6465722f626f7965722d6d6f6f72653f7374796c653d736f6369616c)](https://camo.githubusercontent.com/edf7a7a703e796c6100c8b1ced00304fa595827ae91374b47edc5b40139d8ff6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f616e686f6465722f626f7965722d6d6f6f72653f7374796c653d736f6369616c)

Requirement
-----------

[](#requirement)

```
"symfony/polyfill-mbstring": "^1.23"
```

Install
-------

[](#install)

```
composer require anhoder/boyer-moore
```

Usage
-----

[](#usage)

```
require './vendor/autoload.php';

$text = 'ababa';
$matcher = new \Anhoder\Matcher\BoyerMooreMatcher('aba');
$res = $matcher->match($text, \Anhoder\Matcher\BoyerMooreMatcher::MODE_REUSE_MATCHED);
var_dump($res);
```

- `BoyerMooreMatcher::MODE_ONLY_ONE`: 匹配到一个就返回
- `BoyerMooreMatcher::MODE_SKIP_MATCHED`: 找出所有匹配的字串，已匹配的字符不参与后续匹配，例如：在`ababa`中搜索`aba`结果为`[0]`
- `BoyerMooreMatcher::MODE_SKIP_MATCHED`: 找出所有匹配的字串，已匹配字符继续参与匹配，例如：在`ababa`中搜索`aba`结果为`[0, 2]`

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~8 days

Total

2

Last Release

1700d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27605589?v=4)[anhoder](/maintainers/anhoder)[@anhoder](https://github.com/anhoder)

---

Top Contributors

[![anhoderai](https://avatars.githubusercontent.com/u/125627975?v=4)](https://github.com/anhoderai "anhoderai (4 commits)")[![anhoder](https://avatars.githubusercontent.com/u/27605589?v=4)](https://github.com/anhoder "anhoder (1 commits)")

---

Tags

boyer-mooreboyer-moore-algorithmchinesephpstring-matcherunicodeChineseBoyer-Moorestring match

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anhoder-boyer-moore/health.svg)

```
[![Health](https://phpackages.com/badges/anhoder-boyer-moore/health.svg)](https://phpackages.com/packages/anhoder-boyer-moore)
```

###  Alternatives

[symfony/string

Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way

1.8k724.1M824](/packages/symfony-string)[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[overtrue/pinyin

Chinese to pinyin translator.

4.5k6.5M72](/packages/overtrue-pinyin)[voku/portable-utf8

Portable UTF-8 library - performance optimized (unicode) string functions for php.

52322.4M40](/packages/voku-portable-utf8)[jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

6737.4M62](/packages/jbroadway-urlify)

PHPackages © 2026

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