File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programming Diversions and the fly likes WordFinder redux ... String Searching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "WordFinder redux ... String Searching" Watch "WordFinder redux ... String Searching" New topic

WordFinder redux ... String Searching

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The wordfinder puzzle is already gone! I played a bit with a (possibly) faster string searcher. Back in the 80s I remember a lot of excitement about the Boyer-Moore search algorithm. It can be much faster than checking each position for a match, and gets even faster on longer search strings. Here's a description on Moore's Best Ideas page.

Rather than implement Boyer-Moore (which is awfully complicated) I took the first half of the algorithm from memory and made this.

with tester

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: WordFinder redux ... String Searching
It's not a secret anymore!