[Gambas-user] LIKE operator bug?

Leonardo Miliani leonardo at ...1237...
Mon Sep 8 23:53:27 CEST 2008


Stefano Palmeri ha scritto:
> Il lunedì 8 settembre 2008 22:50:26 Stefano Palmeri ha scritto:
>> I've this code and I want to filter all not-digits from an
>> alphanumeric string.
>>
>>
>> PUBLIC SUB Main()
>>
>>   DIM sAllChars, sSingleChar, sFiltered AS String
>>
>>   sAllChars = "1,2,A,B,C,D,é,é,a,x,ç,5,7,G,°,§,$,&,£,1,2,3,4"
>>
>>   FOR EACH sSingleChar IN Split(sAllChars)
>>
>>     IF sSingleChar LIKE "[^0-9]" THEN
>>       CONTINUE
>>     ELSE
>>       sFiltered = sFiltered & sSingleChar
>>     ENDIF
>>
>>   NEXT
>>
>>   PRINT sFiltered
>>
>> END
>>
>>
>> but the result is "12ééç57°§£1234". It seems that LIKE gets confused by
>> some special chars. I don't know whether this is a bug or something else.
>>
>> My Gambas version is 2.7.0
>>
>> Saluti,
>>
>> Stefano Palmeri
>>
> 
> p.s.: my english is not perfect, so to be clear, I expect
> this result from previous code:
> 
> 12571234
> 
> Saluti
> 
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge Build the coolest Linux based applications with Moblin SDK & win
>> great prizes Grand prize is a trip for two to an Open Source event anywhere
>> in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 

It's the "^" character that seems to have some problems, because if you
invert your test and do the string adding when the test is true (when
the char IS in the interval 0-9), everything goes correctly and you get
the right result:

  IF sSingleChar LIKE "[0-9]" THEN
    sFiltered = sFiltered & sSingleChar
  ENDIF

Gives 12571234

P.S:
Gambas 2.8.2

-- 
Ciao.
Leo.

Web: www.leonardomiliani.com
E-mail: leonardo at ...1237...
Scegli software opensource - Choose opensource software

Co-fondatore di Gambas-it.org
Il sito di riferimento della comunità italiana degli utenti di Gambas
www.gambas-it.org




More information about the User mailing list