If you're looking to get the number at the beginning of the string:

<cfset primayKey = REMatchNoCase('^#[0-9]+',str)>

That will return an array with, using your current string, a single index.

If you're wanting to get ALL numbers from the string:

<cfset primayKey = REMatchNoCase('[0-9]+',str)>

That returns the same array with, using your current string, two indexes.

-----Original Message-----
From: Matthew Smith [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 06, 2008 9:45 AM
To: CF-Talk
Subject: extracting numbers from a string

I am parsing a paypal history(csv) to update records in a databse.

Here is an example of one of the values from one line of the csv:
"#47-Pepper - 10 votes"

The first number is the primary key from the db. I can parse it, but I am
limited to 4 digits long with my solution, and it is not very elegant.
Here's what I have:

<cfset primarykey = mid(detail, 3, 1)>
<cfif isnumeric(mid(detail, 4, 1))>
   <cfset primarykey = primarykey & mid(detail, 4, 1)> </cfif> <cfif
isnumeric(mid(detail, 5, 1))>
   <cfset primarykey = primarykey & mid(detail, 5, 1)>
</cfif>   
<cfif isnumeric(mid(detail, 6, 1))>
   <cfset primarykey = primarykey & mid(detail, 6, 1)> </cfif>

Is there a better way to do what I am trying to do?

Thanks.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312121
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to