Reg Exp Help needed

Discussion in 'PHP' started by anantshri, Apr 13, 2010.

  1. #1
    can any one provide me with a regular expression that can convert.

    http://www.youtube.com/watch?v=xC5uEe5OzNQ
    PHP:
    http://www.youtube.com/v/xC5uEe5OzNQ?f=playlists&app=youtube_gdata&hl=en_US&fs=1&rel=0
    PHP:
    the changes are instead of watch?v= it will be /v/ and rest are all constant.

    can anybody help.
     
    anantshri, Apr 13, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $text = preg_replace('%/watch?v=%'. '/v/', $text);
    PHP:
    That said you would probably be better off using parse_url(), parse_str() and http_build_query() to achieve this properly
     
    JAY6390, Apr 13, 2010 IP
  3. anantshri

    anantshri Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    thanks for the link
     
    anantshri, Apr 13, 2010 IP