foxhunter wrote:
Why join`r`n is needed, although there are 'r'n at each end of the line of variable declaration?
Because by default, AutoHotkey uses only "`n" to join the lines inside "brackets", so you will have:
Line01`n Line02`n Line03\`nLine04\`n Line05\`nLine06\`n Line07\`n
by using "join`r`n", you will have:
Line01`r`n Line02`r`n Line03\`r`nLine04\`r`n Line05\`r`nLine06\`r`n Line07\`r`n
foxhunter wrote:
Why `a is required in the regex options, but \R does not (" \R means "any single newline of any type", namely those listed at the `a option")?
- Windows interprets "`r`n" as new line -
- Linux interprets "`n" as new line -
- Classic Mac OS interprets "`r" as new line -
by default, regex interprets only "`r`n" as new line, but when "`a" is in use, regex recognizes any type of newline, namely `r, `n, `r`n, `v/VT/vertical tab/chr(0xB), `f/FF/formfeed/chr(0xC), and NEL/next-line/chr(0x85).
so, in your first example, since you didn't use "join`r`n" nor "`a" option, the regex multi-line option "m" interprets all the string inside "haystack" variable as an unique line!
Examples:
Line01`n Line02`n Line03\`nLine04\`n Line05\`nLine06\`n Line07\`n
- "m)" regex interprets all the string above as an unique line!
- "m`a)" regex detects 7 lines from the string above
Line01`r`n Line02`r`n Line03\`r`nLine04\`r`n Line05\`r`nLine06\`r`n Line07\`r`n
- "m)" regex detects 7 lines from the string above
- "m`a)" regex detects 7 lines from the string above