RosettaCodeData/Task/Longest-common-substring/PureBasic/longest-common-substring.basic

17 lines
300 B
Plaintext

Procedure.s lcs(a$,b$)
If Len(a$)>Len(b$) : Swap a$,b$ : EndIf
l=Len(a$)
For c=1 To l
For i=1 To 1+l-c
If FindString(b$,Mid(a$,i,c))
res$=Mid(a$,i,c)
EndIf
Next
Next
ProcedureReturn res$
EndProcedure
t1$="testing123testing"
t2$="thisisatest"
Debug lcs(t1$,t2$)