On Jun 24, Richard Adams said:

> @peptides = $sequence =~ /(\w{4}S\w{4})/g;
>
>this works up to a point, but if there are 2 adjacent 'S' the 2nd one
>is not extracted, I guess because the regexp engine continues after the
>end of the previous match ie., it doesn't extract DFRSSSGHY above.

Here's the trick for you:

  @peptides = $sequence =~ /(?=(\w{4}S\w{4}))/g;

The (?=...) assertion "looks ahead" in the string for the pattern, without
actually advancing in the string when it's done.  In this way, we capture
something without advancing past it.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to