Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Strip part of url

by silent11 (Vicar)
on Feb 11, 2011 at 19:41 UTC ( #887667=note: print w/replies, xml ) Need Help??

in reply to Strip part of url

my $url = ""; my @parts = split /\//, $url; (my $numbers )= $parts[-1] =~ m/(\d+)/; print $numbers; # 1234

Replies are listed 'Best First'.
Re^2: Strip part of url
by roboticus (Chancellor) on Feb 11, 2011 at 20:53 UTC


    That's a bit wordy, and you're using multiple regular expressions. If you make your regular expression a little more complex, you can do it like this:

    my $url = ""; my $numbers = $url; $numbers =~ s#^.*(\d+)[^/]*$#$1#; print $numbers;


    When your only tool is a hammer, all problems look like your thumb.

Re^2: Strip part of url
by htmanning (Monk) on Feb 11, 2011 at 20:00 UTC
    Perfect. Thanks so much!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887667]
[Discipulus]: M4ver1k are you debug/dump vars in the loops? are you sure you are not quitting the loop earlier?
[Corion]: A good weekstart to everybody!
[Discipulus]: good morning nuns and monks! hello Corion

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-11-20 08:08 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (285 votes). Check out past polls.