Home  |  Linux  | Mysql  | PHP  | XML
From:Ronald J Kimball Date:Sun Oct 31 17:46:01 2004
Subject:Re: [MacPerl-AnyPerl] Filter a url
On Sun, Oct 31, 2004 at 01:48:10PM +0100, Eelco Alosery wrote:
> Hello,
> 
> I want to filter a url from $ENV{'HTTP_REFERER'}
> If the url is http://www.testdomein.nl/test.html
> I only want a result testdomein.nl
> 
> I have been testing whit this script
> $url =~ s/.*?\.(.+?)\/.*?/$1/is;
> 
> It delets the first part of the url corect, but after .nl it deletes 
> the slash and not the remaining tekst.
> The result is testdomein.nltest.html
> 
> What is it i do wrong.

.*? matches as few characters as possible.  Since it's at the end of your
regex, it never has to match anything.

This will work better:

$url =~ s,.*?\.(.+?)/.*,$1,is;

You may have to tweak it for URLs such as this:

http://testdomein.nl/test.html

Ronald
Navigate in group perl.macperl.anyperl at sever nntp.perl.org
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants