Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: split string and always get last word

by sulfericacid (Deacon)
on Mar 02, 2006 at 02:22 UTC ( [id://533789]=note: print w/replies, xml ) Need Help??


in reply to Re: split string and always get last word
in thread split string and always get last word

I'll post a non-split solution. IRL I'd probably use a regex for this anyway.
my $string = "/alex/samsung/t2"; $string =~ m/(.+)\/(.+)$/; print "$1, $2";


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re^3: split string and always get last word
by matze (Friar) on Mar 02, 2006 at 11:40 UTC
    Another regexp if you don't need the path:
    my $string = "/alex/samsung/t2"; $string =~ m/([^\/]+)$/; print $1, "\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-20 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found