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 -1You 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).
>DEFINE CLASS test > PROCEDURE init > IF ATC("DEFINE CLASS",x)>0 > * > ENDIF > IF ATC("PROCEDURE",x)>0 > * > ENDIF > ENDPROC > PROCEDURE destroy > ENDPROC >ENDDEFINE >>
>RegExp = NEWOBJECT( "_RegExp", "RegExp.vcx" ) >ctext=FILETOSTR("tt.prg") >? RegExp.execute( ctext, [(\bdefine class\b)], .F., .T.) >? RegExp.execute( ctext, [(\bprocedure\b)], .F., .T.) >>