Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7829819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:55:31+00:00 2026-06-02T10:55:31+00:00

I want to parse a specific url variable key value from a url stored

  • 0

I want to parse a specific url variable key value from a url stored as a string. It seems that you can use the underlying java library coldfusion.util.HTMLTools under ACF, but I need it to work under Railo as well. Is there another way, or is using a regular expression the best answer?

I’m trying to retrieve the value of the url variable key without the anchor in a url formatted like the following example.
http://example.com?key=134324625625435#gid=0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:55:40+00:00Added an answer on June 2, 2026 at 10:55 am

    I was posting as a comment on Scott’s answer, but it was getting too long, so…

    John wrote:

    Running the following example I end up with the value of 0,
    but I think it should be the entire key value?

    <cfoutput>
        <cfset theUrl = "https://docs.google.com/spreadsheet/ccc?key=0AthiZNZ73LBndUzRTUkplbmNhYWc##gid=0" />
        <cfset theUrl = listRest(theUrl, "?")>
        <cfloop list="#theUrl#" index="URLPiece" delimiters="&">
            Key: #listFirst(urlPiece, "=")# Value: #listLast(urlPiece, "=")# <br />
        </cfloop>
    </cfoutput>
    

    The reason for failure of that example URL is it contains a page segment (the bit after the hash), which needs to be stripped off before the query string can be parsed.

    It’s also important to get the correct variables/values by wrapping the key/value parts in UrlDecode.

    Plus, it is perfectly acceptable to have an equal sign in the value, so ?key== should return = as the value, which means changing the ListLast to a ListRest and setting includeEmptyFields to true.

    Also, if you have a querystring such as ?a&b then the convention is to set the value to either true or empty string – the current code is setting to the key name, which is wrong.

    In summary, here’s a function:

    <cffunction name="getParamsFromUrlString" returntype="Struct" output=false >
        <cfargument name="UrlString" type="String" required />
        <cfargument name="Separator" type="String" default="?" />
        <cfargument name="Delimiter" type="String" default="&" />
        <cfargument name="AssignOp"  type="String" default="=" />
        <cfargument name="EmptyVars" type="String" default="" />
    
        <cfset var QueryString = ListRest( ListFirst( Arguments.UrlString , '##' ) , Arguments.Separator ) />
        <cfset var Result = {} />
    
        <cfloop index="local.QueryPiece" list=#QueryString# delimiters="#Arguments.Delimiter#">
    
            <cfif NOT find(Arguments.AssignOp,QueryPiece)>
                <cfset Result[ UrlDecode( QueryPiece ) ] = Arguments.EmptyVars />
            <cfelse>
                <cfset Result[ UrlDecode( ListFirst(QueryPiece,Arguments.AssignOp) ) ]
                    =  UrlDecode( ListRest(QueryPiece,Arguments.AssignOp,true) ) />
            </cfif>
        </cfloop>
    
        <cfreturn Result />
    </cffunction>
    

    It can be used as simply as:

        <cfset theUrl = "https://docs.google.com/spreadsheet/ccc?key=0AthiZNZ73LBndUzRTUkplbmNhYWc##gid=0" />
        <cfset Data = getParamsFromUrlString( theUrl ) />
        <cfdump var=#Data# />
    

    Or it can be used on complicated non-standard URL strings like this:

        <cfset theUrl = "https://somewhere/index.jsp;x:145;y:54;z:1;f;d:%23%23;w:%3B" />
        <cfset Data = getParamsFromUrlString( theUrl , ';' , ';' , ':' , 'true' ) />
        <cfdump var=#Data# />
    

    And (hopefully) everything in between.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm attempting to remove specific parameters from the URL query string that are
I want to parse the input string and extract the values from it. My
I want to parse the result of a specific URL using Simple Ajax for
I want to build hits engine that simulate users hits to specific Url, I
We want our coders to NOT use DateTime.parse() . How can we block to
I want to parse, process and then overwrite only 1 specific column in a
I want to parse a filter string similar to the following: ((Field1 = 'red')
I want to parse a descriptive-style URL with slashes (such as server/books/thrillers/johngrisham/thefirm ), in
I want to parse out each modified file that is reported during FCIV's verification
I want to parse the tabular information from a .pdf file,and want to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.