String Division

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Alcrkai
Posts: 47
Joined: 16 Mar 2021, 10:51

String Division

Post by Alcrkai » 06 Jul 2021, 04:30

Good Morning. How can I divide a string by spaces. In the case that it takes a string as a name and separates the first and last name by spaces.

Example:

James Kayser

String 01 =James
String 02 Kayser

mcl
Posts: 361
Joined: 04 May 2018, 16:35

Re: String Division

Post by mcl » 06 Jul 2021, 04:37

Code: Select all

strParts := StrSplit("James Kayser", " ")
MsgBox % strParts[1] "`n" strParts[2]

Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: String Division

Post by Rohwedder » 06 Jul 2021, 09:17

Hallo,
or:

Code: Select all

StringSplit, String0,% "James Kayser" ,% " "
MsgBox,% String01 "`n" String02

User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: String Division

Post by boiler » 06 Jul 2021, 09:19

Note that the StringSplit command is deprecated and no longer recommended for new scripts.

Post Reply

Return to “Ask for Help (v1)”