Split text into sectioned list

My Snap! foo has gone away :frowning:

How do I split some text on the word "words"
e.g.

This is sentence of words with lots of words in it

into a list
timestampSearchReplaceDev script pic

Use this block:

split [This is sentence of words with lots of words in it] by [words v]

That'll remove all the instances of "words", the OP wants to keep them.

Yeah, I just realized that. Sorry!
This works:

Alternatively, if this is easier to understand (it does, however, require you to make a custom block to use it easily):

That works on the basic level, but since the split block is case insensitive (if case sensitivity it turned off), that doesn't preserve the case of "words" in the original string.

However, my block does preserve case.

Here's the block definition. It uses the strings, multiline input library.

Here is a simpler version that maintains case:

Although technically, that leaves a space at the beginning of the first item and the end of the last item in the list. So, in the end, my code is about the same length as @ego-lay_atman-bay's one. Oh, well, here is how to compensate:


PS: OP, if you don't understand something in any of the code I have posted, feel free to ask, and I will explain.

The problem with your script, is that it's restricted to only handling splitting around words surrounded by spaces, not anything not surrounded with spaces.

I specifically designed my script to not be limited by that.
untitled script pic - 2024-09-13T112056.154

Oh, I see! That makes sense. Nice work!

The simple 1st solution was fine for my present needs but I'll use and save one of the advanced ones for future use :slight_smile:

@mark4sisb I liked your keep items code to get all items in list except last one :slight_smile: I normally use

My spec was for words in sentences - I'm actually wanting it to split text encoded blocks
e.g

That makes sense, and I have done similar stuff like only using a simple but limited solution, because it fits my needs. That's what I love about searching for programming solutions (or asking on a forum) rather than asking an ai. An ai usually only gives you one solution that may not fit your needs, however searching for stuff yourself gives you multiple options to choose from, giving you the choice to use a simple vs an advanced script, based on your needs.

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