Hey everyone, I’m getting weird functionality with my split functions. Here is an example of a string I’m splitting: ‘|this|is|my|string|variable|’ which is the value of vMyStringVariable
When I do: Split(vMyStringVariable, “|”)(2)
It equals out to: ‘is’
Rather than: ‘is|my|string|variable|’
Anyone else have similar issue? I’ve tried using a different delimiter with the same result.
Why is element 0 and 6 Blank? In your example the pipe (|) delimiter is being used at the beginning and at the end of the string
Here is how I would expect the string to look before splitting it ‘this|is|my|string|variable’
You should use the delimiter to indicate that one element has ended and that another element exists next to it. You should not use a delimiter to mark the beginning and ending of your elements
No I understand why 0 is blank I wasn’t asking about that. I was wondering if I’m splitting the string after the third rendition of the pipe character why isn’t it returning everything after the third rendition? Rather it is returning everything in between the third and fourth rendition.
Sort of like the difference between: split(vMyStringVariable, “|”)(3)
And: split(split(vMyStringVariable, “|”)(3), “|”)(0)
I’m used to the split function when I have the same delimiter acting like this:
split(vMyStringVariable, “|”)(3)
Not this: split(split(vMyStringVariable, “|”)(3), “|”)(0)
when you split an item - you are taking each string that comes before and after a delimiter and assigning it to its own element in an array.
when you add the (2) to the end of your split command, you are specifying that you want the third element of the array resulting from the split command.
I’ll try to test something out for you- just to confirm: is your desired output ‘is|my|string|variable|’
we are going to expand on the response from @Srini84 with this solution (we will be having some fun with the substring command with a bit of nesting in between!)
One last thing- We can try to use some combination of the SplitTake and Join Commands to put all of this in a one liner. I’d be very interested in putting that together if you want.
Hey @Mr_Meeseeks I get that the substring option works, I know it works. I’ve just used the split command on prior bots and could have sworn that it was not working in the way it currently does. I mean if I’m splitting a string after the second rendition of a character or word why it give me everything after that but prior to the next rendition of that same word? Shouldn’t it just give me everything after that to the end of the current string?
we split the vMyStringVariable string and throw each string into 1 of 7 boxes. Each string has its own box. then we select the string in the 3rd box. We are not selecting the third box and everything that comes after it. However - we can totally do that!
The split command can be used to accomplish what you want, but not without some additional commands.