Helgef wrote: ↑13 Jun 2018, 12:59
Pos will be
0 if there is no match in v2. In v2,
outputvar is a
match object if there is a match.
By default, a dot matches any single character which is not part of a newline (`r`n) sequence,
Note,
`r`n, not single
`n. v2 docs says the same, it is probably not updated,
v2 changes wrote:RegEx newline matching defaults to (*ANYCRLF) and (*BSR_ANYCRLF); `r and `n are recognized in addition to `r`n.
Cheers.
Yes, in Ahk v1, better use
`a flag option for your regex -- `a recognizes any type of newline
@ie,eg: see the following behavior:
Code: Select all
; >>>>>>>>> Run Code
stdout := FileOpen("*", "w")
; O) flag option is for getting match object
Pos := RegExMatch("xyz`nabc`n", "O)^.*$" , match)
stdout.WriteLine("-----")
stdout.WriteLine(". matches ``n")
stdout.WriteLine(Pos . ": " . match.Value)
Pos := RegExMatch("xyz`rabc`r", "O)^.*$" , match)
stdout.WriteLine("-----")
stdout.WriteLine(". matches ``r")
stdout.WriteLine(Pos . ": " . match.Value)
Pos := RegExMatch("xyz`r`nabc`r`n", "O)^.*$" , match)
stdout.WriteLine("-----")
stdout.WriteLine(". do not matches ``r``n")
stdout.WriteLine(Pos . ": " . match.Value)
Pos := RegExMatch("xyz`nabc`n", "`aO)^.*$" , match)
stdout.WriteLine("-----")
stdout.WriteLine(". do not matches ``n; cuz you use ``a) flag option -- ``a recognizes any type of newline => this is the desire behavior")
stdout.WriteLine(Pos . ": " . match.Value)
Pos := RegExMatch("xyz`nabc`n", "s`aO)^.*$" , match)
stdout.WriteLine("-----")
stdout.WriteLine(". do matches ``n; cuz you use s) flag option -- dotAll")
stdout.WriteLine(Pos . ": " . match.Value)
; >>>>>>>>> Output
; >"E:\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "C:\Users\Zlgtx\Desktop\AHK scripts\Test\Test2.ahk"
; -----
; . matches `n
; 1: xyz
; abc
;
; -----
; . matches `r
; 1: xyz
; abc
; -----
; . do not matches `r`n
; 0:
; -----
; . do not matches `n; cuz you use `a) flag option -- `a recognizes any type of newline => this is the desire behavior
; 0:
; -----
; . do matches `n; cuz you use s) flag option -- dotAll
; 1: xyz
; abc
;
; >Exit code: 0 Time: 0.2791