CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Post deleted by anoopam9

 



aman123
New User

Nov 4, 2010, 2:36 PM

Post #1 of 3 (4236 views)
Post deleted by anoopam9

 


Zhris
Enthusiast

Nov 4, 2010, 6:31 PM

Post #2 of 3 (4227 views)
Re: [anoopam9] modify a URL [In reply to] Can't Post

This might be a practical expression:


Code
my $url = 'http://www.abc.com/def/ghi.html';     
$url =~ s/^((http\:\/\/)?[^\/]+).*$/$1/;
print "$url";


Personally I would use the URI module:


Code
use URI; 
my $url = 'http://www.abc.com/def/ghi.html';
my $uri = URI->new($url);
my $domain = $uri->host;
print "$domain";


Chris


(This post was edited by Zhris on Nov 6, 2010, 6:03 AM)


perlJunkie
Novice

Dec 27, 2010, 12:08 AM

Post #3 of 3 (3860 views)
Re: [anoopam9] modify a URL [In reply to] Can't Post

my $url = 'http://www.abc.com/def/ghi.html';
if($url =~ m#(.*//.*?)(/)#) {
print "$1\n";
}

This is possibly another way. I kinda like using the URI module that somebody else pointed out. That was pretty nice.

Using different delimeters makes regex much much easier.
Peace gluck.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives