Pages tagged "text"

Simple Implementation of Wildcard Text Matching using Java

The quick brown fox jumps over the lazy dog

What if you had to implement a text matching logic in Java that would result in an affirmation for search strings such as Th*ick*b*ox*over the*dog, *fox*dog and a negative for ones such as *fox*brown and *abcd*?

I faced a similar challenge few days back as part of another tool I was working on. I wanted a simple solution that not only worked but worked faster. Using a regular expression wasn’t feasible as the search pattern was dynamic and hence, precompiling the expression for faster performance was ruled out.

I thought for a while and arrived at this solution. Hope it helps some hapless programmer like me slogging the night out in some corner of the globe.

13 May 2008