Finding the last instance of a character in a string with StirSplit and InString with AutoHotkey

I thought I’d demonstrate a bit more how InStr() and StirSplit work.  In the below example I work through how to find the last comma in each row of data.

StirSplit and InString with AutoHotkey

 

String=
(
Dallas,Fort Worth, TX
Coppell,TX
Old town, Alexandria, VA
Novato,CA
)

;*********Use For loop over Var going line by line*********************
for i, row in Loopobj:=StrSplit(String,"`n","`r") { ;use For loop to parse over line breaks
	 S:=StrSplit(Row)
	 for k, v in S
		m(k,v)
	Pos:=InStr(Row,",",,0,1)
	MsgBox % SubStr(Row,1,InStr(Row,",",,0,1)-1) "`r`r" trim(SubStr(row,InStr(Row,",",,0,1)+1))
	
}
return

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.