Page 1 of 1

maxsplit parameter for StrSplit

Posted: 24 Mar 2015, 16:23
by GeekDude
Similar to python's str.split's parameter.

Python's docs wrote:If maxsplit is given, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is not specified or -1, then there is no limit on the number of splits (all possible splits are made).

As for a use case example:

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus

Re: maxsplit parameter for StrSplit

Posted: 31 Dec 2017, 00:05
by lexikos
This is simple to implement, but are we sure the Python way is the most intuitive?

For instance, I would probably want "at most n substrings" rather than "at most n splits|n+1 substrings", which means I would have to do mental math when using the function or reading the code.

Re: maxsplit parameter for StrSplit

Posted: 31 Dec 2017, 10:09
by GeekDude
I agree, and though I don't remember making this request it appears I thought the same thing at the time. The sample code I shared in the original post uses 2 as its max split parameter, in order to split the string into a max of two parts.

In python, you'd have to specify 1 to split into two parts.

Re: maxsplit parameter for StrSplit  Topic is solved

Posted: 13 Jan 2018, 20:02
by lexikos
The preview of v1.1.28.00 adds a MaxParts parameter.

Edit: v1.1.28.00 has been released.