When I run this
str = Red Green Blue \Big\Small\Med
s:=StrSplit(str,"\")
T1:= s.1
T2:= s.2
MsgBox % T1
MsgBox % T2
T1 is good for me but T2 equals "Big". I want "\Big|Small\Med" (With all 3 back slashes). In some cases there may be more or less back slashes. I just want everything after the first one including that first back slash. Thanks
string split results
Re: string split results
maxparts:
Code: Select all
str = Red Green Blue \Big\Small\Med
a := StrSplit(str, "\", , 2)
MsgBox % a[1]
MsgBox % a[2]
Re: string split results
Thanks for taking the time to respond here. I'm getting a error here. "Error: Too many parameters passed to Function" I went back to the AHK String Split page and tried to change a few things but I'm not able to get this.
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: string split results
Update to the most recent version and the error should go away. (I tested it myself on version 1.29)
Re: string split results
Latest release is assumed unless otherwise explicitly specified.
If you can't update, you can parse it with a regexp instead.
regexmatch(haystack, "([^\\]*)(.*)", match)
If you can't update, you can parse it with a regexp instead.
regexmatch(haystack, "([^\\]*)(.*)", match)
Re: string split results
And via InStr. Cheers.
Code: Select all
q::
vText := "Red Green Blue \Big\Small\Med"
if (vPos := InStr(vText, "\"))
vText1 := SubStr(vText, 1, vPos-1), vText2 := SubStr(vText, vPos+1)
else
vText1 := vText, vText2 := ""
MsgBox, % "[" vText1 "]" "`r`n" "[" vText2 "]"
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: string split results
I've got so much to learn here. I've been trying to get by with 1.21 for years now because I did not want to mess with what seemed like a good thing. I went ahead and updated to 1.30 and the original script from swagfag now works fine and so far everything else seems to be okay. I guess time will tell. Thank you all for the input here.