Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 May 2000 16:06:17 -0400
From:      Mitch Collinsworth <mkc@Graphics.Cornell.EDU>
To:        Charles Randall <crandall@matchlogic.com>
Cc:        Dan Larsson <dl@tyfon.net>, questions@FreeBSD.ORG
Subject:   Re: regexp driving me nuts, help needed! 
Message-ID:  <200005112006.QAA87986@larryboy.graphics.cornell.edu>
In-Reply-To: Message from Charles Randall <crandall@matchlogic.com>  of "Thu, 11 May 2000 13:56:10 MDT." <5FE9B713CCCDD311A03400508B8B3013B256B8@bdr-xcln.is.matchlogic.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

>That seems like a lot of work,
>
>% echo http://www.domain.com/www.blah/html.asp | perl -ne 'print $1,"\n" if
>m|http://www\.([^/]+)|i'
>domain.com
>
>This will work with a big list of URLs on stdin.

But only as long as they all have "www." in the domain name:

% echo http://domain.com/www.blah/html.asp | perl -ne 'print $1,"\n" if
m|http://www\.([^/]+)|i'
%

Woops.  I guess mine is more flexible:

% echo http://domain.com/www.blah/html.asp |\
 perl -e '$u=<>; $u=~s/http:\/\///; $u=~s/^www.//i; $u=~s/\/.*$//; print $u'
domain.com


-Mitch


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005112006.QAA87986>