;AHK v1MsgBox, % InStr(vText," ",0,0);20 ;search from the last character backwardsMsgBox, % InStr(vText," ",0,-1);15 ;search from the 2nd-to-last character backwardsMsgBox, % InStr(vText," ",0,-5);15 ;search from the 6th-to-last character backwardsMsgBox, % InStr(vText," ",0,-6);10 ;search from the 7th-to-last character backwards;MsgBox, % InStr(vText, " ", 0, 1-n) ;search from the nth-to-last character backwards

;AHK v1 (equivalent)MsgBox, % InStr(vText," ",0,1-1);20 ;search from the last character backwardsMsgBox, % InStr(vText," ",0,1-2);15 ;search from the 2nd-to-last character backwardsMsgBox, % InStr(vText," ",0,1-6);15 ;search from the 6th-to-last character backwardsMsgBox, % InStr(vText," ",0,1-7);10 ;search from the 7th-to-last character backwards;MsgBox, % InStr(vText, " ", 0, 1-n) ;search from the nth-to-last character backwards

;AHK v2MsgBox, % InStr(vText," ",0,-1);20 ;search from the last character backwardsMsgBox, % InStr(vText," ",0,-2);15 ;search from the 2nd-to-last character backwardsMsgBox, % InStr(vText," ",0,-6);15 ;search from the 6th-to-last character backwardsMsgBox, % InStr(vText," ",0,-7);10 ;search from the 7th-to-last character backwards;MsgBox, % InStr(vText, " ", 0, -n) ;search from the nth-to-last character backwards

MyVar = 1,2,3,4Sort, MyVar, F ReverseDirection D,; Reverses the list so that it contains 4,3,2,1ReverseDirection(a1, a2, offset){return offset ; Offset is positive if a2 came after a1 in the original list; negative otherwise.}

;understanding custom sort functions:

;if want a1 to be earlier in the new list return a negative number;if want a2 to be earlier in the new list return a positive number;if want a1 to be later in the new list return a positive number;if want a2 to be later in the new list return a negative number;if offset is negative, a2 was earlier in the original list;if offset is positive, a1 was earlier in the original list

;sort: unstable;ordinarily sorting by the Sort command is unstable,;i.e. in a case insensitive sort:;two items that are regarded as identical may be movedvText :="A,a,a,a,a"Loop,5{Sort, vText, D,MsgBox, % vText}

(continuation sections) ['var = value' style continuation sections will not be present in AHK v2](if (var1 = var2)) [if statements without round brackets are deprecated](if var is type)(var := expression) ['var = value' is deprecated)[AutoTrim will not be present (or needed) in AHK v2][if var in/contains due to be replaced in AHK v2][Transform will not be present in AHK v2]Chr/Ord [Asc is deprecated]Format [SetFormat will not be present in AHK v2]InStr [StringGetPos is deprecated]RegExMatch/RegExReplaceStringCaseSenseStringLower/StringUpper [will be replaced with StrLower/StrUpper in AHK v2, Format can also change case]StrLen [StringLen is deprecated]StrPut/StrGetStrReplace [StringReplace is deprecated]StrSplit [StringSplit is deprecated]SubStr [StringLeft/StringRight/StringTrimLeft/StringTrimRight/StringMid are deprecated]Trim/LTrim/RTrimVarSetCapacity

I would personally recommend that the following functions be added to AHK:- StrContains/StrIn/StrStarts/StrEnds (or a versatile 'StrMatch' function) (note: 'if var in/contains' are due to replaced anyhow)- StrRept- StrCount (cf. StrReplace's OutputVarCount parameter)Possibly also (one reason is for quick conversion from other programming languages):- StrLeft/StrRight/StrTrimLeft/StrTrimRight

Note: users can create custom functions for these, however each would be unique to the user, and would require the function be included with the script, and it would be better to have one core function, where everyone knows how the function works, than to read through the code for various custom functions. Also some user-made custom functions might have drawbacks that an official function wouldn't have.

@nnnik: Any more details, or even an alternative strings tutorial are quite welcome. I do like to consider all viewpoints.

@Helgef: Cheers. I did include a little on StrGet and StrPut in the link below, I had thought of it more of an 'encoding' issue than a strings issue, but I will add it to this tutorial in one or two places, e.g. at least in a list of string functions/commands and also re. overwriting text, which StrPut is useful for.jeeswg's characters tutorial - AutoHotkey Communityhttps://autohotkey.com/boards/viewtopic.php?f=7&t=26486