Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Based on Oleg's answer to "How can I split tab-delimited strings in Autohotkey?"
- ; https://stackoverflow.com/q/45620437/3357935
- ; Split tab-delimited string to a 2D array
- SplitToArray(unsplitString) {
- lines := StrSplit(unsplitString, "`n")
- columns := []
- for index, value in lines
- columns.Insert(StrSplit(value, "`t"))
- Return columns
- }
- ; Split arbitrary-delimited string to a 2D array
- SplitToArray(unsplitString, separator:="`t") {
- lines := StrSplit(unsplitString, "`n")
- columns := []
- for index, value in lines
- columns.Insert(StrSplit(value, separator)) ; defaults to `t
- Return columns
- }
- ; Examples
- columns := SplitToArray(clipboard)
- MsgBox % columns[1][1] ; Unit
- MsgBox % columns[1][2] ; Dept_ID
- MsgBox % columns[1][3] ; Name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement