You are here: Re: Hard time with a regex... « PHP Programming Language « IT news, forums, messages
Re: Hard time with a regex...

Posted by taps128 on 11/30/07 06:34

Charles wrote:
> Hello,
>
> I'm trying to extract the home page URL out of a any URL from the same
> web site
> For instance if I'm on http://www.regular-expressions.info/javascriptexample.html
> I want to extract http://www.regular-expressions.info
> So, I have my regex ready, it's working fine: http://[\w.-]+
> But when I add it to PHP's preg_match function this way:
>
> preg_match('/http\:\/\/\[\\w.-\]+/','http://www.regular-
> expressions.info/javascriptexample.html',$matches);
>
> I get this error message:
>
> Warning: preg_match() [function.preg-match]: Delimiter must not be
> alphanumeric or backslash
> I'm a little lost, I read this page http://www.php.net/manual/en/function.preg-match.php
> and I wasn't able to find what is wrong. On the page they put slashes
> around the regex, sometimes they don't... Do you know what is causing
> the error message?
> Thanks,
>
> --
> Charles.
Or just use this if you are running the script on the server whose name
you are trying to find: $_SERVER["SERVER_NAME"]

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация