in reply to Re: how to remove characters before and after a search pattern in a string?
in thread how to remove characters before and after a search pattern in a string?

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;
  • Comment on Re^2: how to remove characters before and after a search pattern in a string?
  • Download Code