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?

I don't see the difference bewteen
Last GTT:

s/^.*GTT.{3}//s
and
Every GTT:
s/^.*GTT.{3}//s
. Shouldn't it have been
s/^.*GTT.{3}$//s
?

Also, won't the last one remove everything preceding the last occurrence of GTT (assuming it's followed by 3 somethings), and not just every occurrence of 'GTT' within the string?

Replies are listed 'Best First'.
Re^3: how to remove characters before and after a search pattern in a string?
by ikegami (Patriarch) on Mar 03, 2010 at 18:23 UTC

    There isn't any difference. Deleting everything before every instance and deleting everything before the last instances gives the same result.

    No, adding $ makes it so it will only match if GTT is three characters from the end of the string (or 4 if the last character is \n).