Forum Moderators: coopster

Message Too Old, No Replies

Preg_match help

         

BlackRaven

4:04 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



How do you find '.ebay.' in the $URL string when using preg_match

$URL='http://cgi.ebay.com/MICROSOFT-XBOX-XBOX360-WIRED-CONTROLLER_W0QQitemZ82904146';
$test=preg_match('/.ebay./', $URL);

In the above preg_match i am getting false positives for anything that contains "ebay". How do i adjust my preg_match so that only urls contanining ".ebay." are flagged and not something like "ebayeresr" or ".ebayrearesfsdf"

Little_G

4:27 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



Hi,

try escaping the dots:
$test=preg_match('/\.ebay\./', $URL);

Andrew

FalseDawn

4:40 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



You could try something like
'.*[.]ebay[.].*$' for your regex, but stristr would be a much better option for a simple search like this:

[us2.php.net...]

BlackRaven

4:44 pm on Jun 4, 2006 (gmt 0)

10+ Year Member



thanks