Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 684 Bytes

File metadata and controls

52 lines (32 loc) · 684 Bytes

aho-corasick-search

Aho-Corasick for search string

Example

var ahoCorasick = require('aho-corasick-search')

var acSearch = new ahoCorasick();

acSearch.add('1234')
acSearch.add('23')
acSearch.build()
var res = acSearch.search('1234')
console.log(res)

output

[ '23', '1234' ]

Install

npm install aho-corasick-search

Constructor

var acSearch = new ahoCorasick();

Method

acSearch.add(keyword)

put the keyword to the trie

acSearch.build()

build the aho-corasick automaton on the trie

acSearch.search(str)

search all keywords appearing in the str

Return an array containing all appeared keywords