I have the following needle, but the named subpattern Path contains the comment.
How can this needle be improved?
Code: Select all
NeedleInclude = O)^\s*#Include\s+(\*i )?(?P<Path>.*)(\s+;(?P<Comment>.*))?
Code: Select all
String =
(
test
#Incl C:\FileB ;comment
test
test
#Incl *i C:\File C ;comment
test
test
#Incl C:\Path A\File D.ahk
)
NeedleInclude = O)^\s*#Incl\s+(\*i )?(?P<Path>.*)(\s+;(?P<Comment>.*))?
Loop, parse, String, `n, `r
{
If RegExMatch(A_LoopField, NeedleInclude, Match){
Found .= A_Index " " Match.Path "`n"
}
}
MsgBox %Found%