Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-19-2012, 07:59 AM   PM User | #1
cyberhostbd
New Coder

 
Join Date: Sep 2011
Location: USA
Posts: 27
Thanks: 3
Thanked 1 Time in 1 Post
cyberhostbd is an unknown quantity at this point
Please help with with Regex Pattern

I'm trying to match following url but couldn't come up with right pattern.
PHP Code:
www.blahblahblah.com/show/index.php?product=item1 
I just want to match this part only from the html
PHP Code:
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.
__________________
TV Repair in Dallas
cyberhostbd is offline   Reply With Quote
Old 10-20-2012, 10:01 PM   PM User | #2
bjarneo
New Coder

 
Join Date: May 2012
Posts: 50
Thanks: 6
Thanked 4 Times in 4 Posts
bjarneo is an unknown quantity at this point
Actually you don't need to use regex if you only want to match those urls.
Try strstr()

Example:
PHP Code:
$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
bjarneo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:09 PM.


Advertisement
Log in to turn off these ads.