On Nov 27, Dax Mickelson said:

I am having problems matching ALL possible matches of a string against
another (very large) string.  I am doing something like:  @LargeArray =
($HugeString =~ m/$Head......../ig);  Where $Head is an 8 character
string.  (Basically I want to get all 16 character long substrings out of
$HugeString where the first 8 characters match $Head.)

My problem comes about when (for example) I want to match a 16 character
string that starts with AAAAAAAA.  Suppose $HugeString=AAAAAAAAAASDFGHJKL
and $Head=AAAAAAAA  I want @LargeArray[0]=AAAAAAAAAASDFGHJ,
@LargeArray[1]=AAAAAAAAASDFGHJK, and @LargeArray[2]=AAAAAAAASDFGHJKL

So you want to get OVERLAPPING matches, is that correct? If so, your problem can be solved with a "look-ahead" assertion:

  my @matches = $string =~ /(?=($pattern.{8}))/g;

The look-ahead matches without advancing in the string.

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to