File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Q: Best way of matching strings? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Q: Best way of matching strings?" Watch "Q: Best way of matching strings?" New topic

Q: Best way of matching strings?

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
An example of what I am trying to do is match a string such as lo?lip?p (the
?s are the missing letters in a crossword clue for example) to the words
which fit the blanks in a wordlist file.
How can you match a string (where there are wildcards) to another string? I
have looked at compareTo but I don't think that is the right way to do it.
The wordlist is implemented in a binary tree and, to search for matches, the
program does an inorder traversal
Can anyone offer any hints or URLs etc.
paul wheaton

Joined: Dec 14, 1998
Posts: 20972

I think your best bet is to go all the way and get a regular expression engine.

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Another very popular regexp package is GNU regexp. When the ORO software was unavailable for a while last year, this seemed to be generally regarded as the bast.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: Q: Best way of matching strings?
jQuery in Action, 3rd edition