this now would return the length of the match in characters.. however if there were more matches..it will also include it....which is not i want. i just wanted the the longest match in charcters between the two string.

January 30th, 2009, 08:31 PM

slick

Re: longest match Substring between two Strings

i also like the idea of the regrex... but as i was working over the few day... i did make some progress.
this is my new program.. the entire class.

now to follow this...what it does is that it takes two strings.. the second string it breaks it up into all permutations and then compare it to the first. it would then suppose to return a list of all the matches it finds in both strings..
for example if the first string were hello and the second were mello.. this what the program will actually do.

please Enter the First String
hello
please Enter the Second String
mello
[mello, ello, llo, lo, o]
as you can see it gives me all the possible permutations of mello to campare to hello.
if i compare them now it suppose to return alist of all matches, example; ello would match, hence ello would be return.
this is actuall happen, but the problem now is that the program is appending the mathces and returning the result.
example;
please Enter the First String
hello
please Enter the Second String
mello
[, ello, ellollo, ellollolo, ellolloloo]
so u would see now that ello was matched, then llo but it was added on to ello first before returning.. this is where i got stuck..
i think the problem is with the LCM method.
that is