I hacked this piece of code together. It may work for you or it may not. I think it is pretty straightforward, except for the two-level Schwartzian transform-like anonymous array nesting (Data::Dumper should help, though)...
#!perl use strict; use warnings; my $string = "EICHENBAUMSCHULE"; my @query = qw/EIC BAUM UMS CHU LE/; @query = sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] } grep { $_->[1] > -1 } map { [$_, index($string, $_), index($string, $_) + length($ +_) - 1] } @query; my @matches; @query or die "No matches"; my $i = -1; my $p = -2; for (@query) { if ($p + 1 < $_->[1]) { ++$i; } push @{$matches[$i]}, $_; $p = $_->[2]; } @matches = sort { $b->[0] <=> $a->[0] } map { [$_->[-1]->[2] - $_->[0]->[1] + 1, $_] } @matches; print "Longest continuous match has length $matches[0]->[0]\n\n"; print "$string\n"; for (@{$matches[0]->[1]}) { print ' ' x $_->[1] . $_->[0] . "\n"; }
Hope this helped.
CombatSquirrel.
Entropy is the tendency of everything going to hell.

In reply to Re: Regexp string concat by CombatSquirrel
in thread Regexp string concat by Murcia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.