StringUtils.contains Apache and Boyer-Moore String Search Algorithm

To search for s in S (size (S)> = size (s) and return true / false), it is better to use Apache's StringUtils.contains () for performance or use the Boyer-Moore algorithm and well experienced someone I found ?

thanks

+4
source share
2 answers

The last time I looked at Java regex matching code while debugging, the Java 7 regex engine used the Boyer-Moore algorithm for sequences of matches of literal text. Thus, the easiest way to find Stringusing Boyer-Moore is to prepare using p=Pattern.compile(searchString, Pattern.LITERAL)and search using p.matcher(toSearchOn).find(). No third-party libraries and no manual work is required. And I believe that the JRE classes are well tested ...

+8
source

Apache Lang uses Java API compliance for its implementation. It is hard to say that faster on the surface. It sounds like an opportunity to build a simple test case and run it in both directions and see.

0
source

All Articles