I've written this special splitter so you can easily split a text value by multiple delimiters but what result should it give with a input of "one, two.three four " and seperators of , space .
or this (my preferred option)
I've written this special splitter so you can easily split a text value by multiple delimiters but what result should it give with a input of "one, two.three four " and seperators of , space .
or this (my preferred option)
That's good, but it already exists: Split by Delimiters
Mine wasn't good - it was a bodge solution
I'll use the other one and nice to know it behaves in my preffered manner
Just for "fun" - I've created a JavaScript based version that uses RegEx expressions to determine how the text is split
I’m afraid @bombmanyeeted’s split-by-delimiters is (IMAO) flawed though, as demonstrated by changing the order of delimiters:
Here’s for an alternative approach:
Please excuse me for misspelling “delimiters”.
Well spotted
Thanks for an improved version
But what should this report? I'd say it should report a list with 1 empty item.
IMO the empty list is fine.
here's my version
i used recursion to split up the text
Your version is much faster
The difference is spectacular!
The trick that @joecooldoo employs is using as a hyperblock - very smart, hadn't thought of that before.
It does have one issue, though:
Solution:
The latter script is considerably slower than @joecooldoo's, though still much faster than my previous proposal. This is caused by the filter, I guess. Perhaps @joecooldoo can speed it up again
Update: one way to speed it up is moving the code from within inner loop
to a self-contained block - I wonder why that is.
I'd modified joecooldoo's to use a helper block but I like your method of using a variable to save the hassle of having a helper
This has been a good little exercise
My latest version is (corrected version 4Mar2023 21:29UTC]
which assumes that if your only supply one parameter, then you want to treat it as a RegEx value
Philosophy is that if you just wanted a split by one value and not use RegEx then you'd use the standard split by reporter
thats not a bug.
primitive snap SPLIT BY block:
in fact thats what the other programming languages I tested did as well
python:
javascript:
ruby:
rust:
go:
Wow. That certainly proves your point. (Also, nice VS Code theme.)
I agree, my mistake!
I'm getting deeper down the rabbit hole...
The drive behind a multiple delimiter split for me, is to easily parse Advent of Code type problems such as this one
So my latest version will map the split(s) over the input if the input is a list
And you can pre-split the input text into a list to deal with data like the above