Skip to main content
Inspiring
Dec 15, 2017 4:18 PM UTC
Answered

Get value from CGI string

I have cgi.path_info that is always formatted like this

/data/show/80865


How do I get the ALWAYS numeric value after show/

For example, in this case, I want to get the 80865 value.

    This topic is closed to new replies. Start a new post to keep the conversation going.
    WolfShade
    WolfShadeCorrect answer
    Legend
    Dec 15, 2017 4:47 PM UTC

    This can easily be done, if you treat the value as a list with / being the delimiter.

    <cfset variables.thisNumber = ListLast(cgi.path_info,'/') />

    HTH,

    ^ _ ^

    3 replies

    WolfShade
    WolfShadeCorrect answer
    Legend
    Dec 15, 2017 4:47 PM UTC

    This can easily be done, if you treat the value as a list with / being the delimiter.

    <cfset variables.thisNumber = ListLast(cgi.path_info,'/') />

    HTH,

    ^ _ ^

    Translate
    weezerboyAuthor
    Inspiring
    Dec 15, 2017 8:06 PM UTC

    As always, thank you.

    Translate
    WolfShade
    Legend
    Dec 15, 2017 8:33 PM UTC

    Thank you for marking my answer as correct.  I do appreciate it.

    V/r,


    ^ _ ^

    BTW.. for anyone who likes complex for the sake of complexity you can use RegEx.

    <cfset variables.thisNumber = REmatch("\d+$",cgi.path_info)[1] />

    Translate