Situation:
- With TF_Find you can find the linenumbers and/or text of lines containing specific words, the text to search for is a regex
- To speed up the function I've added a quick check at the beginning (see commented line with RegExMatch(Text, SearchText) to see if file or variable contains the RE at all, it not simply return 0 otherwise it would proceed to parse a file on a line by line basis for no good reason
- Now it may happen that if you use the ^ (start of line) option it returns 0 because of course it tries to Match the very first line but because TF_Find operates on a line by line basis that can be inaccurate - see sample list below
- So, just to be sure it tries to find actual lines I have to make sure the m option (multi line) is always passed on in this RegExMatch(Text, SearchText)
- I'm currently testing the code below (red lines) and it seems to work but perhaps fellow AutoHotkey-ers have some other suggestions which may be more fool proof.
list=
(join`r`n
test
test
data1
test
test
data2
test
)
XTF_Find(list,1,0, "is)^data", 0, 1)
XTF_Find(Text, StartLine = 1, EndLine = 0, SearchText = "", ReturnFirst = 1, ReturnText = 0)
{ ; complete rewrite for 3.1
[color=red] If (RegExMatch(SearchText, "^[^)m]*\)") > 0) ; check if m = multiline option is present otherwise it might incorrectly return nul
{
SearchText:= "m" . SearchText
MsgBox % SearchText
}[/color]
; If (RegExMatch(Text, SearchText) < 1) ; this I need to "fix"
; Return "0" ; SearchText not in file or error, do nothing
; process text removed
}
Suggestions welcome. Note you don't have to use the TF library, the above is enough code to run it...




