Skip to main content
Inspiring
September 10, 2008
Answered

Determine if query result begins with a number

  • September 10, 2008
  • 1 reply
  • 551 views
I have query results like this

123PKM
AAPL
WB
9865W
CF
QRST

How can I determine if the query result begins with a number?
Like 123PKM and 9865W do begin with a number.

But the others dont.
    This topic has been closed for replies.
    Correct answer Newsgroup_User
    The refind() would do that task very easily. Not tested, but I think
    this would be the idea.

    <cfoutput>#refind('^[0-9]',myQuery.aField,1,false)#</cfoutput>

    The ColdFusin documentation all over the place will fully define the
    capabilities of the refind() function. It will even provide some basics
    of the regular expression syntax used by this function.

    1 reply

    Newsgroup_UserCorrect answer
    Inspiring
    September 10, 2008
    The refind() would do that task very easily. Not tested, but I think
    this would be the idea.

    <cfoutput>#refind('^[0-9]',myQuery.aField,1,false)#</cfoutput>

    The ColdFusin documentation all over the place will fully define the
    capabilities of the refind() function. It will even provide some basics
    of the regular expression syntax used by this function.
    Inspiring
    September 10, 2008
    weezerboy wrote:
    > How can I determine if the query result begins with a number?

    Another option is to determine that inside your sql query using string functions. For MS SQL you could use patindex()

    SELECT PATINDEX('[0-9]%', someColumn) AS StartsWithNumber,
    otherColumns ...
    FROM someTable

    In your query results the StartsWithNumber column would contain either: 1 (true) or 0 (false).