in reply to Finding a LCS module on word level

Have you tried combining Algorithm::LCS with split?

Replies are listed 'Best First'.
Re^2: Finding a LCS module on word level
by st_ale (Novice) on May 09, 2008 at 00:08 UTC
    Yes, I have tried, but as I mentioned above, like the string1 "perl find perl module" and string2 "perl module", it will return me the "perl" in the front and the "module"in the back, instead of return me the consecutive "perl module" in the back.This is what I do not expect... Thanks.
      My bad -- I was thinking of Algorithm::Diff, which gives you what you want, specifically LCSidx.
        educated_foo,
        As has been pointed out elsewhere, subsequence ne substring. Algorithm::Diff doesn't deal with substrings only subsequences.

        Cheers - L~R

      Your question is still a little unclear to me, but this will give you the consecutive "perl module".

      #!/usr/bin/perl use strict; use warnings; use String::LCSS_XS qw(lcss); my $longest = lcss ( "perl find perl module", "perl module"); print $longest, "\n";
        Khen1950fx,
        Presumably, the distinction the OP is trying to make between chars and words has to do with matching the entire word as well as white space.
        Perl Monks is the best What is the best place to eat should produce "is the best" regardless of white space
        Have you ever seen the rain I have never seen the rain should produce "seen the rain" not "ever seen the rain"
        String::LCSS_XS does not do this.

        Cheers - L~R