Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Removing data from a string with Regex

by scain (Curate)
on Nov 15, 2001 at 02:13 UTC ( [id://125440]=note: print w/replies, xml ) Need Help??


in reply to Removing data from a string with Regex

What you need is $from =~ s/@.+//g;; the ".+" matches everything from @ to the end of the string.

Scott

Minor update: Just to be clear, this is probably not the best way to do this, it just happens to work. Specifically, the .+ matches upto but not including the line feed that is at the end of the string, since it came along to $from from $_. In general, you would probably want to chomp $_ and then explicitly add a "\n" to your print statement, so that it is clear what you are doing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-09-15 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.