https://github.com/anhoder/boyer-moore
PHP implementation of Boyer-Moore character search algorithm, support for Chinese.
https://github.com/anhoder/boyer-moore
boyer-moore boyer-moore-algorithm chinese php string-matcher
Last synced: 3 months ago
JSON representation
PHP implementation of Boyer-Moore character search algorithm, support for Chinese.
- Host: GitHub
- URL: https://github.com/anhoder/boyer-moore
- Owner: anhoder
- License: mit
- Created: 2021-09-04T15:18:22.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-12T15:59:18.000Z (almost 4 years ago)
- Last Synced: 2025-01-27T06:15:10.149Z (5 months ago)
- Topics: boyer-moore, boyer-moore-algorithm, chinese, php, string-matcher
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP实现的Boyer-Moore字符搜索算法,支持中文。
PHP implementation of Boyer-Moore character search algorithm, support for Chinese.    
 
## Requirement
```php
"symfony/polyfill-mbstring": "^1.23"
```## Install
```shell
composer require anhoder/boyer-moore
```## Usage
```php
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]`