|
Posted by ZeldorBlat on 11/30/07 02:25
On Nov 29, 8:39 pm, Charles <landema...@gmail.com> 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 onhttp://www.regular-expressions.info/javascriptexample.html
> I want to extracthttp://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 pagehttp://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.
Why not make life easy and use this instead:
<http://www.php.net/parse-url>
[Back to original message]
|