Can anyone give me a hint?I need to validate if a variable contains letters and numbers together. I tried something else didn't work
![Neutral :|](./images/smilies/icon_neutral.gif)
Code: Select all
Var=UDP4324
if (RegExMatch(Var, "i)[^A-Z ^0-9 ]"))
{
MsgBox, OK
}
else
{
MsgBox, NO
}
Code: Select all
Var=UDP4324
if (RegExMatch(Var, "i)[^A-Z ^0-9 ]"))
{
MsgBox, OK
}
else
{
MsgBox, NO
}
Code: Select all
;q:: ;check that string contains at least one number and at least one letter
Var=UDP4324
;Var=aaaaaaa
;Var=1111111
if RegExMatch(Var, "i)(?=.*[A-Z])(?=.*\d)")
;if RegExMatch(Var, "\d") && RegExMatch(Var, "[A-Za-z]") ;equivalent to line above
{
MsgBox, OK
}
else
{
MsgBox, NO
}
return
really realy really thanksssjeeswg wrote: ↑15 Aug 2019, 22:45Cheers.Code: Select all
;q:: ;check that string contains at least one number and at least one letter Var=UDP4324 ;Var=aaaaaaa ;Var=1111111 if RegExMatch(Var, "i)(?=.*[A-Z])(?=.*\d)") ;if RegExMatch(Var, "\d") && RegExMatch(Var, "[A-Za-z]") ;equivalent to line above { MsgBox, OK } else { MsgBox, NO } return
Code: Select all
RegExMatch(var, "i)\d[a-z]|[a-z]\d")
Code: Select all
var := "a`r`n1"
MsgBox, % RegExMatch(Var, "i)(?=.*[A-Z])(?=.*\d)")
Code: Select all
StrHasLettersAndDigits(Var){
return RegExMatch(Var, "is)(?=.*[A-Z])(?=.*\d)")
}
I don’t know anything about the permissible length of function names, but you can experiment:ThumpieBunnyEve wrote: ↑Would this function name be too long?
Code: Select all
Loop 150
str .= "a"
Func(str).Call()
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
MsgBox, % StrLen(A_ThisFunc)
}
After some experimenting seems 253. I think the total is 255 so 253 + the 2 parenthesis is equal to 255.teadrinker wrote: ↑20 Aug 2019, 06:30I don’t know anything about the permissible length of function names, but you can experiment:
Code: Select all
SetBatchLines, -1
Loop {
funcName .= "a"
ToolTip % i := A_Index
} until !ExecScript("#NoTrayIcon`n" . funcName . "()`n" . funcName . "() {`nFileAppend, t, *`n}")
MsgBox, % "Max function name length: " . --i
ExecScript(script) {
shell := ComObjCreate("WScript.Shell")
exec := shell.Exec(A_AhkPath . " *")
exec.StdIn.Write(script)
exec.StdIn.Close()
return exec.StdOut.ReadAll()
}
Code: Select all
// -2 for the beginning and ending g_DerefChars:
#define MAX_VAR_NAME_LENGTH (UCHAR_MAX - 2)
Users browsing this forum: bobstoner289, Chunjee, Google [Bot], macromint, peter_ahk and 338 guests