anhoder / boyer-moore
Boyer-Moore algorithm in PHP(support Chinese).
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/anhoder/boyer-moore
Requires
- symfony/polyfill-mbstring: ^1.23
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-10-13 01:23:38 UTC
README
PHP实现的Boyer-Moore字符搜索算法,支持中文。 PHP implementation of Boyer-Moore character search algorithm, support for Chinese.
Requirement
"symfony/polyfill-mbstring": "^1.23"
Install
composer require anhoder/boyer-moore
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]