Re: Stripping http:// from a string variable
by "Jan Morell" <janman(at)n-jcenter.com>
|
Date: |
Mon, 17 Jul 2000 01:07:19 -0400 |
To: |
"Rich Bowen" <rbowen(at)rcbowen.com> |
Cc: |
"HWG-Languages" <hwg-languages(at)hwg.org> |
References: |
default janman rcbowen janman2 |
|
todo: View
Thread,
Original
|
|
These are the 2 lines that I got to work. I don't know how to combine them,
but they do the trick.
$URL =~ s!^http://!!i;
$URL =~ s!\b/.+!!;
That takes http://somedomain.com/programs/index.html and converts it to
"somedomain.com". I can then use that to create somedomain.com.html
Thanks for getting me pointed in the right direction.
Jan
----- Original Message -----
From: "Jan Morell" <janman(at)n-jcenter.com>
To: "Rich Bowen" <rbowen(at)rcbowen.com>
Cc: "HWG-Languages" <hwg-languages(at)hwg.org>
Sent: Sunday, July 16, 2000 11:56 PM
Subject: Re: Stripping http:// from a string variable
> HI Rich,
>
> Actually the code is working as it should. The problem is that I had not
> considered that there would be URLs that would have characters in them
that
> would not be legal in a file name on a UNIX server. Such as "/". I see
> that now I have to strip everything from the first instance of the "/" to
> the end of the string. That will be another good exercise. Regular
> Expressions are not my strong point.
>
> Jan
>
> ----- Original Message -----
> From: "Rich Bowen" <rbowen(at)rcbowen.com>
> To: "Jan Morell" <janman(at)n-jcenter.com>
> Cc: "HWG-Languages" <hwg-languages(at)hwg.org>
> Sent: Sunday, July 16, 2000 5:16 PM
> Subject: Re: Stripping http:// from a string variable
>
>
> > Jan Morell wrote:
> > >
> > > I have a string variable which contains a URL including the "http://".
> I
> > > want to strip the "http://" from the variable. This is in a Perl
> script.
> > > Example: Change "http://my.com" to "my.com"
> > >
> > > I have tried this with no success.
> > >
> > > $URL =~ s/(^http:\/\/)//;
> > >
> > > Jan
> >
> > Hmm. What you have there should work, except that the ( ) are not
> > necessary. For added readability, perhaps you can try:
> >
> > $URL =~ s!^http://!!;
> >
> > When you say "no success", is the string not modified at all? Perhaps
> > you should add a i on the end of that - maybe the string is really
> > HTTP... rather than http...
> >
> > $URL =~ s!^http://!!i;
> >
> > Hope this helps.
> >
> > Rich
> > --
> > Rich(at)cre8tivegroup.com
> > Director of Web Application Development - The Creative Group
> > http://www.cre8tivegroup.com/
> > Author - Apache Server Unleashed - http://apacheunleashed.com/
> >
>
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA