Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RegExp question
Message
From
09/02/2017 14:01:43
 
 
To
08/02/2017 16:07:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01647702
Message ID:
01647787
Views:
83
Sound Super,

Can you send me a copy of the class (and any dependents) via email ( GregReichert@GLRsoftware.com ). Any required instruction would be appreciated.

My FUnit tool allows the developer to place Unit Test pretty much anywhere in the source code, general close the points needing to be tested. The test suite I am working on, scans the source code, and finds the unit tests. It extracts the locations (file, class, method, etc) of the tests and presents a tree list of the location and the tests to developer. This is where a process like your would help.

>The pattern I provided is an excerpt from what we use in FoxInCloud Adaptation Assistant to work with any code page worldwide.
>
>As I cut it out of a longer pattern, I may have mismatched parentheses.
>
>FWIW we have patterns to match almost anything in a VFP program like define class, method parameters, method and function calls, and more, all packed in a single class.
>
>If you need a broad and bullet-proof approach, it might be useful to you; let me know
>
>>Thanks for the ideas.
>>
>>VFP barked at the embedded '&', but work that out. Then RegExp threw a COM error when executing. it. Is the hex character for international letter sets necessary.
>>
>>>Hi Greg,
>>>
>>>Looking at modify class _regexp of Ffc\_regexp.vcx method execute, it misses the multiline option.
>>>
>>>LParameters tcStr, tlCaseMatters
>>>
>>>Local loRegEx, loMatch, loMatches, i
>>>
>>>loRegEx = CreateObject("VBScript.RegExp")
>>>loRegEx.pattern = this.pattern
>>>loRegEx.ignoreCase = !tlCaseMatters
>>>loRegEx.global = .T.
>>>
>>>loMatches = loRegEx.execute(tcStr)
>>>Dimension this.matches[Max(loMatches.count,1),2]
>>>taMatchInfo = .F.
>>>
>>>i = 1
>>>For Each loMatch In loMatches
>>>	this.matches[i, 1] = loMatch.firstIndex + 1   && fox strings are not zero-based
>>>	this.matches[i, 2] = loMatch.value
>>>	i = i + 1
>>>EndFor
>>>
>>>loMatches = .F.
>>>loRegEx = .F.
>>>
>>>Return i -1
>>>
>>>
>>>You need to instantiate "VBScript.RegExp" yourself:
>>>
>>>loRegEx = CreateObject("VBScript.RegExp")
>>>loRegEx.pattern = this.pattern
>>>loRegEx.ignoreCase = !tlCaseMatters
>>>loRegEx.global = .T.
>>>loRegEx.multiline = .T.
>>>
>>>
>>>Then this pattern should work:
>>>
>>>(^[ \t]*(?=[_\u0041-\u005A\u005F\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0152-\u0153\u0160-\u0161\u0178\u0192#@&=\?\.\\](?!&))(?:(?:HIDD(?:E|EN)?|PROT(?:E|EC|ECT|ECTE|ECTED)?)(?:[ \t]+|(?:[ \t]*;\s*?(?=&&|$).*?$\s+)))*(?:FUNC(?:T|TI|TIO|TION)?|PROC(?:E|ED|EDU|EDUR|EDURE)?)
>>>
>>>
>>>
>>>
>>>>Have been trying to construct a Regular Expression pattern to find a string that only exists at the beginning of a line, even if there are none or more white spaces before it (either spaces or tabs).
>>>>
>>>>Example text I'm search
>>>>
>>>>
>>>>DEFINE CLASS test
>>>>	PROCEDURE init
>>>>		IF ATC("DEFINE CLASS",x)>0
>>>>		*
>>>>		ENDIF 
>>>>		IF ATC("PROCEDURE",x)>0
>>>>		*
>>>>		ENDIF 
>>>>	ENDPROC
>>>>	PROCEDURE destroy
>>>>	ENDPROC
>>>>ENDDEFINE 
>>>>
>>>>
>>>>If I am look for the "DEFINE CLASS" (ignoring the case), I would like for it to find only the "DEFINE CLASS test". Also, If I am looking for "PROCEDURE", I want it to find only the "PROCEDURE init" and "PROCEDURE destory", not the one in the ATC().
>>>>
>>>>Here is a example of the search code I am trying.
>>>>
>>>>
>>>>RegExp = NEWOBJECT( "_RegExp", "RegExp.vcx" )
>>>>ctext=FILETOSTR("tt.prg")
>>>>? RegExp.execute( ctext, [(\bdefine class\b)], .F., .T.)
>>>>? RegExp.execute( ctext, [(\bprocedure\b)], .F., .T.)
>>>>
>>>>
>>>>I realize I need to be including the '^' (start of line), possibly '\s*' for the white spaces. but when I do include them the query fails to find anything. I only want it to find matches that are at the beginning of the lines.
Greg Reichert
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform