Convert a multiline input to a list of words

I have a multiline input field that I want to save as an alphabetical list of words. I don’t want to save it as a list, but just save the alphabetical version in another multiline input.

For example:

Mary had a little lamb

would be saved as

a had lamb little mary

Any suggestions would be massively appreciated as it will help me out of a jam.

How does the value get into the multiline input field? Is it by user input or some other means?

To sort, you’d ideally need to get the data into some sort of array, then you can do it using JavaScript (expression element in toolbox plugin) and return the result but it would be useful to know how the multiline input data gets there in the first place.

Here’s one way you can do it…

Put this code into the Expression element:

// get the multiline input data
var input = “MultilineInput E’s value”;

// split each word by using a space
var output = input.split(" ");

// sort the data
var result = output.sort();

//convert to string (without the commas)
result = result.join(" ").toString();


Have the return type set to text and untick the list option. Put your MultilineInput’s value into it.


Now wherever you want the returned data to appear, just use Expression X’s value, like I’m using in a text field for example.


There are other ways to do this to, if this doesn’t quite suit your needs.


1 Like

That’s great Paul. Really appreciate it and for the step by step instructions too. You’re the man!

I’m also trying to do something similar where my multiline input converts the items into a list. However, for some reason when I setup everything exactly like you suggested, there doesn’t seem to be any text showing up in the text field even though there is text in the multiline input.

Any initial ideas?

Is it just a line by line list of words you are after or do you need them sorting into a particular order?

Just line by line really, doesn’t need to be sorted really.

You can do it with Regex. It is one of the options when selecting what to save. I think it says ‘Extract as Regex’.

Choose that one and then in the Regex Pattern box that comes up put:


That should give you the content of the field you are referencing one word at a time, and then there’s also an option to search.

I am no Regex expert (at all!), but with lots of Googling it is amazing how powerful Regex is and just what you can do with it. Luckily there are lots of awesome people who have already come up with the many of expressions I needed, and so I didn’t actually need to learn Regex. There are also some cool tools for testing our Regex patterns so you can find something that works for you.

Hope that helps Drew. If I can be of any more help let me know. I can’t promise answers, and there are FAR more qualified people on here than me (by a million miles), but if I can help I will.

1 Like

Thanks a lot, that worked well for displaying the text. Do you know if there is a way to reverse this if I wanted to save the list of texts back as a list?

Sorry I didn’t realise using the same Regex to save would work! Thanks so much, this one thing has slowed down my project! Really appreciate your help.

Lol! I’d just finished an answer about that, but it sounds like you’ve figured it out yourself. Awesome! Glad it worked for you. Regex is pretty cool isn’t it :slight_smile:

I’ve just noticed that it seems to not work correctly if there is a space in between two words. Is there a way around this?

When you say it doesn’t work when there’s a space what do you mean? Is it not saving the result as individual words in your data type?

I think I have an action to return an array in the Toolit plug-in. Can you check there

I’m looking for it to pick up single words but also words with a space between them.

This topic was automatically closed after 70 days. New replies are no longer allowed.