Splitting Text Using a Separator

I am curious on how to split strings in GKC as there isn’t a function to do that. What I mean:

Text: Item1/Item2/Item3andExtraCharacters
Input: 2
Output: Item2

I essentially want to slice text from a certain index by splitting the text based on a separator in this case, the “/” to get “Item2.”

Sorry if this is confusing, but I tried my best to explain this.


Should this be in Devices?

BUMPing for a solution.

Try making a repeat function that increases in a loop until it gets a “/” in the index.
Then put that as the 2nd input in a get substring block.

I want this all in blocks, so the loop wouldn’t work unfortunately.

So you want to take each item you have to be put in an individual property? Or do you just want to get the nth element of a list?

The nth element of the list produced by the split.

If you’re looking for a non-loop solution, I would recommend using a different seperator for each element. For example:
e1/ item1 e2/ item2 e3/ brainrot e4/ amongus e5/
(spaces added for clarity. normally there wouldn’t be spaces between elements)

Then, to get the 3rd item:
Find the index of the first occurrence of “e3/”
Find the index of the first occurrence of “e4/”
Then get the substring of text between those two indicies.

5 Likes

https://forum.creative.gimkit.com/t/substring-coma-splicing/134277/32

I had a help topic similar to this problem. @Here_to_help is real good at this type of stuff.
Blue boats idea works too.

2 Likes

I just took a quick look at that, it’s a good recursive solution to put each item of the list into an individual property. Unfortunately, OP is against recursion.

3 Likes

This works! Thanks for your response!

2 Likes

No problem. Have a great day!

1 Like

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.