c++ - Checking if string contains another string algorithm? -


if have string , have many other strings , want see if of other strings in a.

what algorithm in few iterations possible?

ex:

'hello, name bob.'

and want see if 'name b' contained, starting @ [11].

i'm not looking use regular expression library.

thanks

the efficient algorithm aho-corasick algorithm, given string of length n , set of strings of total length m can find matches in time o(n + m + z), z total number of matches reported. it's based on finite automata , generalization of kmp string matching algorithm.

one cool aspect of algorithm if have fixed set of keywords , bunch of text strings want search, algorithm can sped doing o(m) preprocessing build matcher. can find matches in string of length n in time o(n + z).

if, on other hand, have fixed string , want match varying set of pattern strings against it, consider looking suffix trees, give same runtime guarantees faster if text fixed.

hope helps!


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -