Skip to main content
Inspiring
February 13, 2009
Answered

Parse an "inputted" url string

  • February 13, 2009
  • 1 reply
  • 858 views
I am simply trying to parse a URL for a particular value without going through len(), left(), right(), findnocase() hell. Can anyone please tell me how? I feel like I'm missing some obvious function.

Example:
I only want the value of (v).
http://www.youtube.com/watch?v=wHMZa7Qb8XI&feature=yva-title

    This topic has been closed for replies.
    Correct answer BKBK
    Romeogq wrote:
    I really wish there was some function that would parse the inputted url into a standard coldfusion value pair array or structure.

    You can create your own, as I have done below. In fact, in cases like this, more can be less.



    1 reply

    Inspiring
    February 13, 2009
    if v is always the first parameter in the query string, then you can use
    cf list functions to get its value:

    <cfset url = " http://www.youtube.com/watch?v=wHMZa7Qb8XI&feature=yva-title">
    <cfset v_value = listgetat(url, 2, "=")>

    if it is in varying positions in the query string, you'll need a regexp
    to get its value. i am not big on regexp, so will let someone else chime
    in with correct code...

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    romeogqAuthor
    Inspiring
    February 13, 2009
    Thanks for the reply. But yeah, I'm not sure if the (v) value will ever change position... plus I wouldn't want the "&feature" that would be included in listgetat() example. I really wish there was some function that would parse the inputted url into a standard coldfusion value pair array or structure.
    romeogqAuthor
    Inspiring
    February 13, 2009
    Anymore help on this? Maybe somehow using cfhttp??