Regex in what language?

Where do the results need to go?

If CF 5 or less,
To just find the values:

<cfset fileContent="function MyName(sdfkgjslkdf)#chr(10)#fsd gj#chr(10)#;fkjl 
kg;ll;kszf kg;#chr(10)##chr(10)#;lafsk g;lkf 
#chr(10)#g#chr(10)#;#chr(10)##chr(10)#function MyName3(sdfkgjslkdf)#chr(10)#dh 
#chr(10)#ds hf#chr(10)#dfhs d#chr(10)#sfh #chr(10)##chr(10)##chr(10)#">

<cfset startLoc=1>
<cfset loc=refindnocase("function[ ]+([^\(]+)\(",fileContent,startLoc,"True")>
<cfloop condition="loc.pos[1] neq 0">
        <cfset loc=refindnocase("function[ ]+([^\(]+)\(",fileContent,startLoc,"True")>
        <cfif loc.pos[1] eq 0>
                <cfbreak>
        </cfif>
        <cfoutput>
        #mid(fileContent,loc.pos[2],loc.len[2])#<br>
        </cfoutput>
        <cfset startLoc=loc.pos[2]>
</cfloop>

HTH
Jerry Johnson

>>> [EMAIL PROTECTED] 09/06/02 01:18PM >>>
I need to parse a javascript file for function names.  I have a regex that
will find the "function MyName" but I only want the "MyName".

Here's my regex (from memory, so I might not have it right):
        (?:function\s)\S*\(

(which if my understanding is right means a non-grouping search for function
followed by a space or tab, then any number of non-space characters,
followed by a bracket)

Any tips on how to get JUST the function name?  Thanks in advance.


Shawn Grover


______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to