Suppose:
Let>str1=12345neil
Let>str2=125neil
How to get the diffrence "34"? Null replacement is not working..
Difference between two strings
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 63
- Joined: Thu Dec 10, 2009 8:13 am
Assuming the strings being compared are always the same basic pattern as the example, something like the following will work. Functionally, if you start with two identical strings and make additions to ONE of them. The following will be able to find those additions.
Code: Select all
Let>str1=12345neil
Let>str2=125neil
RegEx>.,Str1,0,var1,var1_count,0
RegEx>.,Str2,0,var2,var2_count,0
Let>kk=0
Let>kkk=0
Let>kkkk=0
Let>diff=
If>var1_count>var2_count
Let>var_count=%var1_count%+1
Repeat>kk
Add>kk,1
Add>kkk,1
Label>Test1
If>%kk%<%var_count%
If>var1_%kk%=Var2_%kkk%
Else
Add>kkkk,1
Let>var_%kkkk%=var1_%kk%
Add>kk,1
Goto>Test1
EndIf
EndIf
Until>kk>%var1_count%
Else
Let>var_count=%var2_count%+1
Repeat>kkk
Add>kk,1
Add>kkk,1
Label>Test2
If>%kkk%<%var_count%
If>var2_%kkk%=Var1_%kk%
Else
Add>kkkk,1
Let>var_%kkkk%=var2_%kkk%
Add>kkk,1
Goto>Test2
EndIf
EndIf
Until>kkk>%var2_count%
EndIf
Let>kkkkk=0
Repeat>kkkkk
Add>kkkkk,1
Let>value=var_%kkkkk%
Concat>diff,value
Until>kkkkk,%kkkk%
MDL>diff