Text to array using split

Hello, This one is very tricky. I’ve got a text I get from an API, so I realized that for better filtering of the text I receive I need to split the text using regex (/\n/). I need to create a multi insert in my server action that takes the value “text” splits it and the insert each value to my database.

I’ve got this:

Of course, didn’t work because the value I set (SplitText) is an array without any text inside it, I need to insert the new split text into my database.

Hi

I suspect you want to do this: http://howitisdone.info/splitText1.html

On the page, the paragraph contains all the text from the text field in the database entry. The buttons are generated by repeat from the array.

Code of the paragraph and button:

The structure of the server action is very simple:

This is an example for a single database entry. If you need to do this if there are more than one records in the database, then you will need to insert a repeat in the server action and form an array for each record inside the repeat. Also on the page, you will need to wrap the button in an additional element that will repeat the database entries (in this example, there is no such repeater). In any case, if there are difficulties write. I’ll try to help.

Did not follow the question here.

  1. fullTextAnnotation.text - when you do a SPLIT, does this return an array? You can check that by enabling output in the SplitText variable.
  2. When inside the repeat, based on the SplitText array, you can use the current value in the insert step by using $value. Is this what you are after?
1 Like

Thanks for your time! But, that’s exactly what I already have.

I need to be able to generate a new record for each split word/sentence I have. Why? Because I need to run a query to the database afterwords to get the record based on the sentence (using “contains” expression on my query).

Thanks, it’s working the variable:

image

How do I create a multi insert record for each one of them? I need to create a record for each one. When I try to, it’s like there is no varible inside the array:

So nothing gets inserted on the database…

So for regular strings, the Wappler’s action picker will not show $value. Just double click the field, and instead of clicking the picker icon, just write $value in there.

1 Like

May I say… I love you :laughing:

You’re welcome. :sweat_smile:

1 Like

I’ve got other problem now… On my example I was splitting using " ", but I need to split it using regex using (/\n/).

The .split(/\n/) on the client side works fine, but on the server side, it doesn’t.

anyone? @Teodor

Update: issue solved here Split(php explode) by new line in server connect

Basically, add a new line for the split: