Multi Commander Support Forum

Multi Commander => Feature Requests and Suggestions => Topic started by: Jungle on December 09, 2022, 14:37:47

Title: Multiscript StrSplit improve
Post by: Jungle on December 09, 2022, 14:37:47
Now delimiter param in StrSplit function is used as a single separator. It means that the following code will not split input string

Code: [Select]
@var $str = "123,|456;|,789";
@var $arr = StrSplit($str, ";|,");

I request additional optional param like any_char (0/1):
- with the value 0 the function would have current behaviour;
- with the value 1 the character of the delimiter which has the lowest index in the input string would be used as a delimiter (so in the code above it would be "," char)
- with the value 2 the first found char of the delimiter would be used as a delimiter (so in the code above it would be "|" char)
Title: Re: Multiscript StrSplit improve
Post by: Mathias (Author) on December 10, 2022, 14:31:43
I think I rather add a new split function for it

StrSplitAny($str , ";|." );

Is Option 2 really needed ? if you enter many delimiters . dont you always want it to split at the position where any of the delimiters are found ? (option 1 ?)


Title: Re: Multiscript StrSplit improve
Post by: Jungle on December 10, 2022, 17:20:26
Is Option 2 really needed ? if you enter many delimiters . dont you always want it to split at the position where any of the delimiters are found ? (option 1 ?)

Actually, there may also be 3 option :) The first char of the delimiter param would be the delimiter (";" in the code above). If not found, then the second one etc. So:
- 1st from the input string disregarding delimiters order
- 1st from the input string regarding delimiters order
- 1st from the delimiter string disregarding input string index
Title: Re: Multiscript StrSplit improve
Post by: Mathias (Author) on December 11, 2022, 11:32:15
Is Option 2 really needed ? if you enter many delimiters . dont you always want it to split at the position where any of the delimiters are found ? (option 1 ?)

Actually, there may also be 3 option :) The first char of the delimiter param would be the delimiter (";" in the code above). If not found, then the second one etc. So:
- 1st from the input string disregarding delimiters order
- 1st from the input string regarding delimiters order
- 1st from the delimiter string disregarding input string index

Yes I Know but I find the other case strange. and wonder how useful it really is. adding something just because it can be added is not time well spent.
looking around at split function in other places I find the "Split where the first of ANY of the specified delimiters is found.."  But I can't find any uses for the other options.