Gossamer Forum
Home : General : Perl Programming :

What SHOULD be a simple regex

Quote Reply
What SHOULD be a simple regex
Can someone help me with a regex? Im trying to ignore everything before a / such as http://www.domain.com/whatever/pic.gif. I want to remove everything before the last / (regardless of how many / there may be) so I am only left with only pic.gif


Quote Reply
Re: What SHOULD be a simple regex In reply to
Regex to get pic1.gif....

Code:
$url = "http://www.domain.com/bla/pic1.gif";
Code:
$url =~ s/^.+(\w+\.\w+)$/$1/;
or...

Code:
if ($url =~ /(\w+\.\w+)$/) {
$img = $1;
}
Installations:http://www.wiredon.net/gt/

Quote Reply
Re: What SHOULD be a simple regex In reply to
or just
$url =~ s!.*/!!;

-g


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: What SHOULD be a simple regex In reply to
Bummer Smile

Installations:http://www.wiredon.net/gt/