Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing 2 strings
Message
From
09/08/2008 14:48:22
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01337798
Message ID:
01337801
Views:
13
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform