Re: Stripping http:// from a string variable
by "Jan Morell" <janman(at)n-jcenter.com>
|
Date: |
Sun, 16 Jul 2000 23:56:41 -0400 |
To: |
"Rich Bowen" <rbowen(at)rcbowen.com> |
Cc: |
"HWG-Languages" <hwg-languages(at)hwg.org> |
References: |
default janman rcbowen |
|
todo: View
Thread,
Original
|
|
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