>>Excelent. and with little more doctoring I added the Function too. plus including the name that follows.
>>
>>
>>clear
>>TEXT TO cText NOSHOW TEXTMERGE
>>DEFINE CLASS test
>> PROCEDURE init
>> IF ATC("DEFINE CLASS",x)>0
>> *
>> ENDIF
>> IF ATC("PROCEDURE",x)>0
>> *
>> ENDIF
>> PROTECTED PROCEDURE something
>> ENDPROC
>> HIDDEN PROCEDURE more_sss
>> ENDPROC
>> FUNCTION me(xx)
>> ENDFUNC
>> ENDPROC
>>ENDDEFINE
>>ENDTEXT
>>
>>RegExp = NEWOBJECT( "_RegExp", "RegExp.vcx" )
>>cpat = "^\s*(((hidd(e(n)?)?)|(prot(e(c(t(e(d)?)?)?)?)?))\s+)?((func(t(i(o(n)?)?)?)?)|(proc(e(d(u(r(e)?)?)?)?)?))\s*\w+"
>>? cpat
>>n= RegExp.execute( ctext, cpat, .F., .T.)
>>? n
>>FOR i=1 TO n
>> ?
>>* ?? RegExp.Matches[i,1]
>> ?? RegExp.Matches[i,2]
>>* ?? substr(ctext, regexp.matches(i,1), 20)
>>NEXT
>>
>
>Three notes on this, the first concerning what I previously suggested, the others regarding your changes.
>
>Whenever there is a reference to white space, that is, to "\s", change to "[ \t]": we don't want to have newline characters affecting the matches (otherwise, the pattern will add preceding blank to the matches, and accept broken statements as valid).
>
>Then, after the PROCEDURE or FUNCTION keyword, we need at least a white space character, so it should be "+" instead of "*" (if not, PROCEDUREinit will match the pattern).
>
>Finally, checking the name with "\w+" will fail to correctly interpret contained objects' methods. For instance
>
>
>DEFINE CLASS test AS Form
>
> ADD OBJECT aButton AS CommandButton
>
> PROCEDURE aButton.Click
>...
>
>
>will match "PROCEDURE aButton", and I think you would like to match "PROCEDURE aButton.Click" (if I'm not mistaken).
>
>So, a revised pattern could be
>
>
>m.RegExp.pattern = "^[ \t]*(((hidd(e(n)?)?)|(prot(e(c(t(e(d)?)?)?)?)?))[ \t]+)?((func(t(i(o(n)?)?)?)?)|(proc(e(d(u(r(e)?)?)?)?)?))[ \t]+(\w+(\.\w+)?)"
>
All, excellent points.
(wish UT had not dropped the Email Myself button. it was nice to send a solution to myself)
Greg Reichert