Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LIKE() Wildcards
Message
De
10/02/2016 00:58:04
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
09/02/2016 23:37:06
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., Nouvelle Zélande
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01631173
Message ID:
01631174
Vues:
84
J'aime (1)
Hj John,

it's a bit tricky.

There is no way to escape the quantifiers or to change them.
But then - it's foxpro. Just redefine LIKE
#DEFINE LIKE My_Like

?LIKE("Is this Test ? ?",'myfield 2 ?')

#UNDEFINE LIKE


FUNCTION My_Like
 LPARAMETERS;
  tcExpression1,;
  tcExpression2

 LOCAL;
  llReturn AS BOOLEAN

 llReturn = .F.
 IF LEN(tcExpression1)=LEN(tcExpression1);
   AND RIGHT(tcExpression1,1)=RIGHT(tcExpression2,1) THEN
  llReturn = LIKE(LEFT(tcExpression1,LEN(tcExpression1)-1),LEFT(tcExpression2,LEN(tcExpression2)-1))
 ENDIF &&LEN(tcExpression1)=LEN(tcExpression1) AND RIGHT(tcExpression1,1)=RIGHT(tcExpression2,1)

 RETURN llReturn
ENDFUNC &&My_Like
As you can see, you redirect LIKE to your own function. What you do there is up to you, you can do something like my example with string operations or - what I recomend more - do sometrhing with regular expressions.

HTH
Lutz

>All,
>
>Any idea how I can use LIKE() to find strings containing wildcards?
>
>Example:
>
>
Browse for LIKE("Is this Test ? ?",myfield)
>
>I want it to return
>
>Is this Test 1 ?
>Is this Test 2 ?
>
>Issue is that ? is a wildcard so if used in the LIKE() it returns any character at that position rather than just the ? I want. Ditto *.
>
>I can't find any sys or other settings to change the wildcards. This is just spotted in a very old piece of code that we're not keen to rewrite so I'm hoping somebody must have a clever way to overcome it!
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform