StringMid vs SubStr()
Code: Select all
InputVar := "AutoHotkey"
; StringMid, OutputVar, InputVar, StartChar [, Count , L]
StringMid, OutputVar, InputVar, 5, 3
MsgBox % OutputVar ; Hot
; SubStr(String, StartingPos [, Length])
MsgBox % SubStr(InputVar, 5, 3) ; Hot
Code: Select all
InputVar := "AutoHotkey"
; StringLeft, OutputVar, InputVar, Count
StringLeft, OutputVar, InputVar, 4
MsgBox % OutputVar ; Auto
; SubStr(String, StartingPos [, Length])
MsgBox % SubStr(InputVar, 1, 4) ; Auto
Code: Select all
InputVar := "AutoHotkey"
; StringRight, OutputVar, InputVar, Count
StringRight, OutputVar, InputVar, 3
MsgBox % OutputVar ; key
; SubStr(String, StartingPos [, Length])
MsgBox % SubStr(InputVar, -2) ; key
Code: Select all
InputVar := "AutoHotkey"
; StringTrimLeft, OutputVar, InputVar, Count
StringTrimLeft, OutputVar, InputVar, 4
MsgBox % OutputVar ; Hotkey
; SubStr(String, StartingPos [, Length])
MsgBox % SubStr(InputVar, (4 + 1)) ; Hotkey
Code: Select all
InputVar := "AutoHotkey"
; StringTrimRight, OutputVar, InputVar, Count
StringTrimRight, OutputVar, InputVar, 3
MsgBox % OutputVar ; AutoHot
; SubStr(String, StartingPos [, Length])
MsgBox % SubStr(InputVar, 1, -3) ; AutoHot
Code: Select all
InputVar := "AutoHotkey"
; StringLen, OutputVar, InputVar
StringLen, OutputVar, InputVar
MsgBox % OutputVar ; 10
; StrLen(String)
MsgBox % StrLen(InputVar) ; 10
Code: Select all
InputVar := "AutoHotkey"
; StringGetPos, OutputVar, InputVar, SearchText [, L#|R#, Offset]
StringGetPos, OutputVar, InputVar, Hot
MsgBox % OutputVar ; 4
; InStr(Haystack, Needle [, CaseSensitive = false, StartingPos = 1, Occurrence = 1])
MsgBox % InStr(InputVar, "Hot") ; 5
Code: Select all
InputVar := "AutoHotkey"
; IfInString, var, SearchString
IfInString, InputVar, Hot
MsgBox % "Hot is in AutoHotkey"
; InStr(Haystack, Needle [, CaseSensitive = false, StartingPos = 1, Occurrence = 1])
if InStr(InputVar, "Hot")
MsgBox % "Hot is in AutoHotkey"
Code: Select all
InputVar := "AutoHotkey"
; IfNotInString, var, SearchString
IfNotInString, InputVar, Toy
MsgBox % "Toy is not in AutoHotkey"
; InStr(Haystack, Needle [, CaseSensitive = false, StartingPos = 1, Occurrence = 1])
if !(InStr(InputVar, "Toy"))
MsgBox % "Toy is not in AutoHotkey"
Last Update: 2015-10-08