Multiline Input into List of Texts?

I have a simple multi-line input field where the user inputs a word(s) on separate lines. Let’s call it nicknames. So the user inputs their nicknames into the multi-line input as such:

nickname1
nickname2
nickname3

Now, when I save it, I need to save it into the user’s ‘nickname’ field which is a List of Texts. In the Workflow I’ve tried setting the ‘nickname’ field using the Set List, Add List, and Add methods and I cannot get the list field to populate. I’ve tried using a SPACE/COMMA/SPACE between each nickname on one line and it still doesn’t come into the field as individualized list items.

I can upload a csv file into the database and use the following format for the list items “[nickname1 , nickname2 , nickname3]” (note the brackets). That method works fine… each nickname comes in as its own line item in the List of Texts.

But I can’t figure out how to take the individual lines from the multi-line input and save it as a List of Texts in the Workflow.

Any help and direction is greatly appreciated.

1 Like

Hey @underhill.dan,

I’ve done this before by separating my “list items” in the multiline input with commas (a, b, c, d) and using some regex. Here is the regex you can use for this: [^,]+

Screen Shot 2020-07-24 at 12.10.29 PM

In the above screenshot I’m just setting a custom state that is a list of texts using a multiline input’s value: extract with regex.

Hope this helps!

1 Like

Hey Jacob,

Thanks a ton! I got this to work well as long as there is a comma (,) between each entry in the multi-line input. For example, the following works:

nickname1,nickname2,nickname3 or

nickname1,
nickname2,
nickname3

My last question is how can I Regex this so that my users don’t have to rely on putting a comma in between each nickname. Ideally they can just input nicknames, one per line, without any commas. I’m not that familiar with Regex stuff yet.

EDIT: I tried using the following expression: [^\v]+ and it works using an online Regex tester, but it doesn’t work when I use it here in Bubble.

SOLVED: After a fair bit of experimentation I discovered that the proper syntax to use for Regex to delineate each item on a line-by-line basis is simply [^\n]+

Thanks for the help :slight_smile:

8 Likes

Glad you figured that out — was just about to mention this in response to @jacobgershkovich’s reply. What your final regex does is looks for the newline character (\n) and splits into an array at those points.

1 Like

Thank you for this topic.
However, after using it to try to solve my multi-line input issue I am still unable to achieve my desired functionality.
I want to allow users to enter multiple aircraft they are rated to fly and then “make changes to the thing” their profile with this information.
However, when I create the workflow for the ‘Submit’ button the multi-line input element is not available and says, “Not compatible.”
I’ve attached screenshots and would greatly appreciate any suggestions you may have.

1 Like