Regex for an URL

Discussion in 'PHP' started by eiso, Aug 17, 2008.

  1. #1
    I am looking to parse this url:

    http://www.google.com/search?hl=en&q=keyword+searched&btnG=Google+Search 
    Code (markup):
    and retreive (en) and (keyword+searched) using a preg_match and a regex. I have been trying regex's all day. Does anyone know the regex for this?

    Thank you,

    Eiso
     
    eiso, Aug 17, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    '~[\?&]q=([^&$]+)~
    
    PHP:
     
    nico_swd, Aug 17, 2008 IP