Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparing 2 strings
Message
De
09/08/2008 14:48:22
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01337798
Message ID:
01337801
Vues:
12
>Is there an easy way to compare two string and return what is different ?
>
>stringWichWorks = "http://tira-teima.as.bol.uol.com.br/challengeSender.html?data=SDTMliZ2VLTDiJ3yTOaiSZh6WBKgWVDlKeve0zmxTD7R13tPNpa7yMjzYWRHbQVpX5VvFcwbpsHDpPPvw6maOA1aJbRIgoi7jCTPBoQ647LHvOFZZb9fHOP7SE4Jr0cexq2QFe0Xy89GPolE5sPmrA=="
>
>stringWichFails = "http://tira-teima.as.bol.uol.com.br/challengeSender.html?data=SDTMliZ2VLTDiJ3yTOaiSZh6WBKgWVDlKeve0zmxTD7R13tPNpa7yMjzYWRHbQVpX5VvFcwbpsHD0ApPPvw6maOA1aJbRIgoi7jCTPBoQ647LHvOFZZb9fHOP7SE4Jr0cexq2QFe0Xy89GPolE5sPmrA=="

Depends on your definition of different, and I mean it.

You can start with something as simple as comparing them to the first different byte:
for i=1 to min(len(str1), len(str2))
   c1=left(str1, i)
   c2=left(str2, i)
   if not c1==c2
      ? "First",i,"characters are identical"
      ? substr(c1, i+1)
      ? substr(c2, i+1)
      exit
   endif
endfor

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform