|
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"]
[Back to original message]
|