...

View Full Version : Please help with with Regex Pattern



cyberhostbd
10-19-2012, 07:59 AM
I'm trying to match following url but couldn't come up with right pattern.

www.blahblahblah.com/show/index.php?product=item1

I just want to match this part only from the html

www.blahblahblah.com/show/index.php?product=

I tried following but didn't work-
$pattern = /www.blahblahblah.com\/show\/index.php\?product=/

but didn't work. Plz co-operate.

bjarneo
10-20-2012, 10:01 PM
Actually you don't need to use regex if you only want to match those urls.
Try strstr()

Example:


$url = "www.blahblahblah.com/show/index.php?product=item1";

$pattern = "www.blahblahblah.com/show/index.php?product=";

$result = strstr($url, $pattern);
if($result == true) {
echo 'true';
} else {
echo 'false';
}


Output: true



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum