Reply to Hard time with a regex...

Your name:

Reply:


Posted by Charles on 11/30/07 01:39

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.

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

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