RosettaCodeData/Task/Longest-common-substring/BaCon/longest-common-substring.bacon

14 lines
314 B
Plaintext

FUNCTION Common_Sub$(haystack$, needle$)
WHILE LEN(needle$)
FOR x = LEN(needle$) DOWNTO 1
IF INSTR(haystack$, LEFT$(needle$, x)) THEN RETURN LEFT$(needle$, x)
NEXT
needle$ = MID$(needle$, 2)
WEND
EXIT
ENDFUNC
PRINT Common_Sub$("thisisatest", "testing123testing")