-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
PHP实现的Boyer-Moore字符搜索算法,支持中文。 | ||
PHP implementation of Boyer-Moore character search algorithm, support for Chinese. | ||
|
||
![GitHub repo size](https://img.shields.io/github/repo-size/anhoder/) ![GitHub](https://img.shields.io/github/license/anhoder/go-musicfox) ![Last Tag](https://badgen.net/github/tag/anhoder/go-musicfox) ![GitHub last commit](https://badgen.net/github/last-commit/anhoder/go-musicfox) ![GitHub All Releases](https://img.shields.io/github/downloads/anhoder/go-musicfox/total) | ||
|
||
![GitHub stars](https://img.shields.io/github/stars/anhoder/go-musicfox?style=social) ![GitHub forks](https://img.shields.io/github/forks/anhoder/go-musicfox?style=social) | ||
|
||
## 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]` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* 2021/9/4 12:47 上午 | ||
*/ | ||
|
||
namespace Anhoder\BoyerMoore; | ||
namespace Anhoder\Matcher; | ||
|
||
use RuntimeException; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters