Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: how to remove characters before and after a search pattern in a string?

by jrsimmon (Hermit)
on Mar 03, 2010 at 18:15 UTC ( [id://826482]=note: print w/replies, xml ) Need Help??


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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://826482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2025-02-17 01:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found