Newline is matched only when adding a bracket to s in (s)*R
in Regex in Ahk?
str .= (RegExReplace("`r`n0AAA", "`am)s*R", "1ZZZ")) . "`r`n" ; this one fail to replace, why?
str .= (RegExReplace("`r`n0AAA", "`am)(s)*R", "2ZZZ")) . "`r`n" ; I have to add a bracket to (s) ?
Full code:
#Requires AutoHotkey v1.1.33+
#Persistent
#SingleInstance force
^t::
idx := 0
str := ""
; s* vs (s)*
str .= (RegExReplace("`r`n0AAA", "`am)s*R", "1ZZZ")) . "`r`n" ; this one fail to replace, why?
str .= (RegExReplace("`r`n0AAA", "`am)(s)*R", "2ZZZ")) . "`r`n" ; I have to add a bracket to (s) ?
MsgBox, % str
return
/*
Output:
---------------------------
0AAA
2ZZZ0AAA
*/
^+1:: Reload