1 comment

[ 2.9 ms ] story [ 11.0 ms ] thread
Pure PHP Aho-Corasick algorithm finite state machine) and pattern match with a wildcard and a ternary trie.

Unittest: $tree = new Ahocorasick\Ahocorasick(); $tree->add("AC"); $tree->add("GTG"); $tree->add("AACT"); echo $tree->match("ACCGAGTGCGTGGACAAACTACGATTGTGGAATGAACT","AC*GT"); $this->expectOutputString("ACCGAGT,ACCGAGTGCGT,ACCGAGTGCGTGGACAAACTACGATTGT,ACAAACTACGATTGT,ACTACGATTGT,ACGATTGT");

web+git: https://tetramatrix.github.io/phpahocorasick/