Any preg gurus?

Discussion in 'PHP' started by DW1, Jun 2, 2007.

  1. #1
    :confused:
    I need a preg_replace() to turn
    href="http://ex.com/custom.php?QUERY"
    Code (markup):
    into:
    href="http://ex.com/custom.php?ex=1&QUERY"
    Code (markup):
    Thanks for any help. Meanwhile I'll be here :)

    Regards
     
    DW1, Jun 2, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Try this:
    
    $text = preg_replace('/custom\.php\?([^"]+)/', 'custom.php?ex=1&$1', $text);
    
    PHP:
     
    nico_swd, Jun 2, 2007 IP
  3. DW1

    DW1 Peon

    Messages:
    111
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Works perfectly - I almost had it but for the [^"]+ :) I appreciate your help! :D
     
    DW1, Jun 2, 2007 IP