[Gambas-user] Correctly using the LIKE operator

Mike Keehan Mike at ...680...
Sat Mar 22 17:47:07 CET 2008


MaxVK wrote:
> Hi, I'm having some problems using the LIKE operator.
> 
> I'm trying to use it in a spell check routine, to generate a list of words
> that might be the correct spelling for a word that is not in the dictionary.
> However, I seem to be able to either include almost every word in the
> dictionary, or no words at all!
> 
> I'm doing something like this:
> 
> IF CheckWord LIKE "[" & sp_Dict[d] & "]*" THEN .... add this word to a list
> 
> I have tried using "?[...]?", and "*[...]*" and various similar
> combinations, but I'm still unable to get a satisfactory result, either
> getting words that are in no way 'LIKE' the misspelled word, or getting none
> at all.
> 
> Could anyone point me in the right direction please, or possibly even offer
> an alternative way to do this.
> 
> Many thanks
> 
> Max

Hi Max.

I don't think LIKE will do what you want.

When you code 'IF CheckWord LIKE "[abcd]*" THEN ...', then the IF 
condition is true if CheckWord starts with any of the letters 'a', 
'b', 'c', or 'd'.  The square brackets are used to match against a 
single character of CheckWord.

'LIKE' will not say that 'picure' is similar to 'picture' for example.

I suggest you research (i.e. google) for Soundex, and for correlate.

Best of luck,

    Mike.





More information about the User mailing list