Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    USA
    Posts
    27
    Thanks
    3
    Thanked 1 Time in 1 Post

    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.

  • #2
    New Coder
    Join Date
    May 2012
    Posts
    50
    Thanks
    6
    Thanked 4 Times in 4 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •