Don't do the refind() in the loop.  Running it once with "all" specified 
will return (you're right on this one) a struct of arrays.  It will find 
all of the matches (hence scope "all" :-P).

You then only need to loop over the results.  Much more efficient.

Plus, OMG, you're using a condition that runs the regex and throws away 
the answer.  Don't do that.  Ever.  Please.  It makes me weep.

--Ben Doom

Bobby Hartsfield wrote:
> Likea so...
> 
> <cfset txt = "this is a test testId67Text more text more text testId49Text
> more text testId54Text more text testId56Text" />
> <cfset county = 0 />
> <cfset arrString = arrayNew(1) />
> <cfset nums = arrayNew(1) />
> 
> <cfloop condition="refind('testId(\d+)Text', txt)">
>       <cfset county = county + 1 />
>       <cfset arrString = refind('testId(\d+)Text', txt, 1, true) />
>       <cfset nums[county] = mid(txt, arrString['pos'][2],
> arrString['len'][2]) />
>       <cfset txt = removechars(txt, arrString['pos'][1],
> arrString['len'][1]) />
> </cfloop>
> <cfdump var="#nums#" />
> 
> 
> ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
> Bobby Hartsfield
> http://acoderslife.com
> 
> 
> -----Original Message-----
> From: Ben Doom [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 05, 2007 11:37 AM
> To: CF-Talk
> Subject: Re: Regex search problem
> 
> You can do an
> refind(text, "\d+", 1, "all")
> refind in text digits starting at position one find all
> 
> This will return an array of structs with keys pos and len.  Pos is the 
> start position, and len is the length.  You can then use mid() to grab them.
> 
> --Ben Doom
> 
> Web Exp wrote:
>> Thanks Ray...
>> Ok... I guess I should have clarified that I am using CF MX7, so I
>> cannot use reMatch function.
>> Also, what I am looking for is to find a list of numbers between the
>> strings: "testId" and "Text" in this pattern:
>> "testId67Text more text more text testId49Text more text testId54Text
>> more text". I need to extract 67,49,54.
>> Note: I do not need all the umbers, I want them only if they are
>> present in that pattern.
>>
>> Thanks,
>> K
>>
>> On 11/5/07, Raymond Camden <[EMAIL PROTECTED]> wrote:
>>> Use the number character class.
>>>
>>>
>>> <cfsavecontent variable="test">
>>> testId67Text more text more text testId49Text more text testId54Text more
> text
>>> </cfsavecontent>
>>>
>>> <cfset numbers = reMatch("[[:digit:]]+", test)>
>>> <cfdump var="#numbers#">
>>>
>>>
>>> On Nov 5, 2007 9:30 AM, Web Exp <[EMAIL PROTECTED]> wrote:
>>>> Hi. I have a bunch of text in a db table that has multiple occurances
>>>> of this pattern:
>>>> "testId67Text more text more text testId49Text more text testId54Text
> more text"
>>>> How can I get all the numbers from it? i need 67,49,54.
>>>>
>>>> I know it need regex. But I need help.
>>>>
>>>> Thanks,
>>>> K
>>>>
>>>>
>>
> 
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

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

Reply via email to