we're using "iAD)(exe|bat|com)"
https://github.com/mmikeww/AHK-v2-script-converter/blob/a6aa84fa40a764246f3639b422ba6c2f8223fa01/ConvertFuncs.ahk#L800
It should work just as well with multi-line strings (since it lacks the "m" option), as long the subject doesn't have a trailing line ending (since it lacks the "D" option). I'd bet there are many scripts around that don't take into account the special case of a trailing line ending.
Its 0.52 seconds using iseahounds profiling code.---------------------------
Performance.ahk
---------------------------
RegexMatch produced 1234567 hits in 25.559957399999998 seconds
the map produced 1234567 hits in 0.52017780000000002 seconds
---------------------------
OK
---------------------------
Code: Select all
Msgbox "Mon`n" ~= "i)^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)$" ? "Matched" : "Not Matched" ;"Matched" shouldn't match since "Mon`n"!="Mon"
Msgbox "Mon`n" ~= "Di)^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)$" ? "Matched" : "Not Matched" ;"Not Matched"
Msgbox "Mon`n" ~= "Di)^(Mon`n|Tue|Wed|Thu|Fri|Sat|Sun)$" ? "Matched" : "Not Matched" ;"Matched", perfect
Code: Select all
var:="hello`n"
if var in hello
{
msgbox % "Matched"
} else {
msgbox % "Not Matched" ;HERE
}
var:="hello`n"
if var in hello`n
{
msgbox % "Matched" ;HERE
} else {
msgbox % "Not Matched"
}
Code: Select all
^ start of subject
also after internal newline in multiline mode
\A start of subject
$ end of subject
also before newline at end of subject
also before internal newline in multiline mode
\Z end of subject
also before newline at end of subject
\z end of subject
The non-matching are suppose to be the desired ones, they'll match when the needle contains `r`n.var := "val`r`n"
MATCHED by "i)^(val)$"
MATCHED by "i)\A(val)\Z"
NOT matched by "iD)^(val)$"
NOT matched by "i)\A(val)\z"
Code: Select all
Var := "val`r`n"
Txt := "var := ""val``r``n""`n`n"
Patt := "i)^(val)$"
Txt .= (var~=Patt ? "MATCHED" : "NOT matched") . " by """ Patt """`n"
Patt := "i)\A(val)\Z"
Txt .= (var~=Patt ? "MATCHED" : "NOT matched") . " by """ Patt """`n"
Patt := "iD)^(val)$"
Txt .= (var~=Patt ? "MATCHED" : "NOT matched") . " by """ Patt """`n"
Patt := "i)\A(val)\z"
Txt .= (var~=Patt ? "MATCHED" : "NOT matched") . " by """ Patt """`n"
MsgBox % Txt
Code: Select all
str:=""
str.=("Mon`r`n" ~= "i)^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\z" ? "Matched" : "Not Matched") "`n" ;"Not Matched"
str.=("Mon`r`n" ~= "i)^(Mon`n|Tue|Wed|Thu|Fri|Sat|Sun)\z" ? "Matched" : "Not Matched") "`n" ;"Not Matched"
str.=("Mon`r`n" ~= "i)^(Mon`r`n|Tue|Wed|Thu|Fri|Sat|Sun)\z" ? "Matched" : "Not Matched") "`n" ;"Matched"
Msgbox str
i knew i wasnt smart enough to come up with AD) on my own
might want to change thathttps://www.autohotkey.com/docs/commands/IfIn.htm wrote: The operators "in" and "contains" are not supported in expressions. Instead, use If statements such as if (Var ~= "iAD)Value1|Value2") for "in" or if (Var ~= "i)Value1|Value2") for "contains" to simulate the behavior of these operators.
where contains is really just the reverse of in:if string contains "Sun","Mon","Tues","Wed","Thur","Fri","Sat"
and "Sun","Mon","Tues" is a pseudo tuple type. It doesn't have to be an actual tuple type like in Python. But the reason why it should be comma deliminated, is because the output variables in for...in are also comma deliminated.if "Sun","Mon","Tues","Wed","Thur","Fri","Sat" in string
Return to “AutoHotkey Development”
Users browsing this forum: No registered users and 38 guests