How can I add characters to each line in a multiline input?

I need a way to wrap each line of a multi-line input in quotes in order to use the data with my company’s API. Is there a way to do that with regex, or anything else?

Hi @sethb,

I can think of at least a couple ways. One of them is to first parse the multi-line input into a list of texts. Once you have the list, then you can use the new :format as text operator (announced here) on the list to generate the quoted strings.

2 Likes

:format as text does seem to be what I need, but I don’t see it in the dropdown. Am I looking in the right place?

You’d need a list. That’s why I pointed to the first post, which would enable the multi-line input (via regex) to be converted to a Bubble list.

I’m still working on this.
The regex \S+(\n|$) converts to a list, and with the :format as text operator, I am able to add quotes to the beginning of the values. When I try to add them to the end, they end up at the beginning of the next item in the list. Presumably this is because the regex is starting a new line.

This:

Yields this:
image

I’m new to regex, but it seems like that expression is the problem. Any ideas?

1 Like

Maybe try "This text:trimmed". I think that’ll remove leading and trailing white space, which should include the new line character.

I had to play with things on the API side to make sure this was working correctly, but it is now. I had to convert to a list with regex, use ‘format as text’ to add the quotes along with a comma delimiter, and trim the white space.

Thanks for the help!