Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Identifying differences between two character strings
Message
From
08/07/2003 10:00:49
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00806505
Message ID:
00807957
Views:
20
Hi Glenn,
I spent a little time examining the StrDiff() function
that you submitted because I believe it can be useful.
Here is what I found:
* It will show the difference between two strings ONLY if the
* shorter of the two strings has an EXACT MATCH within the
* the longer of the two strings. The first string
* "The cat jumped over the fence" has an exact match in the
* second string, but "The cat jumped over the fence." (which
* has a period) does not match.
*
* Looks like most of this function should be in a "DO WHILE"
* loop where the shorter string is incrementally compared to the
* longer string until it no longer matches like this:
*
* "The"
* "The cat"
* "The cat jumped"
* .
* .
* .

Thanks for the interesting function.
Terry

---------------------------------------------------------------------

>Depending on the exact requirements this may work
>
>
>funtion StrDiff(tc1,tc2)
>local lcdiff,lc1,lc2
>lcdiff = ''
>if vartype(tc1) = 'C' and vartype(tc2) = 'C'
>  if len(tc1) > len(tc2)
>    lc1 = tc1
>    lc2 = tc2
>  else
>    lc1 = tc2
>    lc2 = tc1
>  endif
>  lcdiff = strtran(lc1,lc2,space(len(lc2)))
>endif
>return lcDiff
>
>
>Glenn
>
>
>if
>>Does anyone know of an existing function, routine, or 3rd-pary product that will show the differences between one character string and another? I'm not totally sure exactly how this would work, but one example follows:
>>Original string = "The cat jumped over the fence."
>>New string = "The cat jumped over the fence to cross the road."
>>Routine would return something like: "to cross the road."
>>Etc...
>>
>>Thanks!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform