print url_parse('http://www.moo.com/moo.cgi?moo=moo'); sub url_parse { my $url = shift; $url =~ m!(http:\/\/[^\/]+)!gis; my $base = $1; ( my $directorystruct = $url ) =~ s!$1!!gis; my ( undef, @directories ) = split /\//, $directorystruct; my $tnum = $#directories; $directories[$tnum] =~ s/(.*)\?.*/$1/gis; return $base . '/' . $directories[$tnum] if scalar(@directories) < += 1; return $base . '/../' . $directories[$tnum]; }
In reply to Re: Regex to Truncate URLs Nicely
by Revelation
in thread Regex to Truncate URLs Nicely
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |