Search code examples
coldfusioncoldfusion-9

Coldfusion Struct getting only numeric key list


I have a coldfusion Struct containing mix keys numeric and alpha, alphanumerics

I need to access only the numeric keys.

My code looks like

<cfset ids = structkeyList(st ) />
<cfset numericIDs = "" />
<cfloop list="#ids#" index="i">
    <cfif IsNumeric(i)>
        <cfset numericIDs = ListAppend( numericIDs , i ) />
    </cfif>
</cfloop>

Is there a better method to solve such problems?


Solution

  • Is there a better method to solve such problems?

    I would use something like this:

    <cfset numericIDs = arrayToList(reMatch('\b\d+(?=,|$)\b', structKeyList(st)))>