Steve,

 

Yep perfecto! Here's what I ended up with. Returns a struct of unique keys
with each key containing a count of the number of occurrences.

 

Run it on itself and you get

 


struct


cfargument

2 


cfdump

1 


cfelse

1 


cffile

1 


cffunction

1 


cfif

3 


cfloop

1 


cfreturn

1 


cfset

10 

 

Thanks for your help, since you are so good at RegEX's I wonder if you might
be interested in attempting to fix the color coding, which is 90% regex's.

 

<cffile action="read" file="#expandPath('test.cfm')#" variable="cf" />

 

<cfdump var="#getTag(cf)#" />

 

<!--- Get a unique list of tags from coldfusion code --->

<cffunction name="getTag"  access="public" returntype="struct">

     <cfargument name="code" type="string" required="true" />

    <cfargument name="sort" type="boolean" default="true" />

    

     <cfset local = {} />

    <cfset local.result = {} />

    

    <cfset local.expression = "<(cf[^ >]*)" />

     <cfif reFindNoCase(local.expression, arguments.code)>

        <cfset local.start = reFindNoCase(local.expression, arguments.code)
/>

         

        <cfloop condition="#reFindNoCase(local.expression, arguments.code,
local.start)#">

            <cfset local.tag = reFindNoCase(local.expression,
arguments.code, local.start, true) />

            <cfset local.key = mid(arguments.code, local.tag.pos[2],
local.tag.len[2]) />

                <cfif NOT structKeyExists(local.result, local.key)>

                     <cfset local.result[local.key] = 1 />           

            <cfelse>

                     <cfset local.result[local.key] ++ />            

                </cfif>

            <cfset local.start = local.tag.pos[1] + local.tag.len[1] />

        </cfloop>

    </cfif>

 

     <cfif arguments.sort>

           <cfset structSort(local.result, 'text') />

     </cfif>

    

     <cfreturn local.result />

</cffunction>

 

 

Regards

Dale Fraser

 

http://dalefraser.blogspot.com

 

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Steve Onnis
Sent: Tuesday, 4 September 2007 10:03 AM
To: [email protected]
Subject: [cfaussie] Re: RegEx Help

 

Dale

 

Was what i sent yesterday any good or not what you were looking for

 

Steve

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Dale Fraser
Sent: Tuesday, 4 September 2007 9:33 AM
To: [email protected]
Subject: [cfaussie] Re: RegEx Help

Charlie,

 

I have already got a Color Coder, which I hacked from the BlogCFC one, as
for many alternatives, I couldn't find anything decent.

 

I actually want it for something else, but if you have a good color coder or
a link to such I would be interested in having a look at it.

 

My one is still a bit buggy.

 

Regards

Dale Fraser

 

http://dalefraser.blogspot.com

 

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Charlie Arehart (lists account)
Sent: Tuesday, 4 September 2007 6:46 AM
To: [email protected]
Subject: [cfaussie] Re: RegEx Help

 

Dale, might you be doing this to create a tool to do color coding in your
learncf code examples? If so, just note that there are many existing
alternatives for that. If you're doing it for some other reason, no worries.
Just thought I'd ask if that might be the real root of the question.

 

/charlie

 

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Dale Fraser
Sent: Monday, September 03, 2007 1:48 AM
To: [email protected]
Subject: [cfaussie] RegEx Help

I struggle with RegEx's

 

Anyone know if this is even possible.

 

I want to pull out a unique list of coldfusion tags in a given source string

 

I assume I can match

 

<cf*[space]

 

Can the regex do the unique bit, or do I need to loop through and build a
structure.

 

Regards

Dale Fraser

 

http://dalefraser.blogspot.com

 

<BR

<BR


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to