Probably better as:
my $str = "ACGTTGGCTATTGGGCCCGCT"; my $pattern = "GTT"; if ( ( my $offset = index $str, $pattern ) >= 0 ) { + substr $str, 0, $offset + length( $pattern ) + 3, ""; } print $str;
In reply to Re^2: how to remove characters before and after a search pattern in a string?
by jwkrahn
in thread how to remove characters before and after a search pattern in a string?
by BhariD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |