regular expression help...

Discussion in 'PHP' started by zurc, Feb 1, 2007.

  1. #1
    $str = 'http://websitename/folder/index.php?pagez=load_searched&c=43&s=1&p=1';

    how do I remove the '&p=1';
    from the $str using regular expressions..
     
    zurc, Feb 1, 2007 IP
  2. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I guess the problem is that the '1' is not always a '1', otherwise you can use str_replace('&p=1', '', $str), right?

    Is it always a number? If so:
    $pattern = '/&p=\d+/';
    $new_str = preg_replace($pattern, '', $str);
    PHP:
    Are you trying to do add a pagination feature? ;)
     
    picouli, Feb 1, 2007 IP
  3. zurc

    zurc Banned

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    no just practicing regular expressions :) anyway thanks I'm going to try it... just want to know some tricks using regular expressions.
     
    zurc, Feb 1, 2007 IP