How to wrap each line user enters and saves to a database?

I have a column where the user can save a multiple-line input. Is there any way I can wrap each line with some given tags?

For example: the user puts

Some line 1
Some line 2

But it should be saved in my database as

[Label]Some line 1[/Label]
[Label]Some line 2[/Label]

Is there any way to do so?

Thanks in advance!

Spit the text into a list of texts
Format the list as text
For each list item write [Label]This Text[/Label]
Then split the text back into a list of texts (assuming you need to)

1 Like

I’d rather save with a find&replace…

save it with:
[Label]multilinetext:trimmered:find&replace[/Label]

then in the find&replace you could put:

find:
(press an enter to find a breakline)

replace:
[/Label]
[Label]

if you don’t want to have empty data with labels, you should have another find&replace before ripping of empty lines

there’s probably other solutions with regex, but I’m not an expert

another solution, if you don’t want to change the database, is to set the transformations where the text will be shown

Thanks! Find & Replace did the job just like how I wanted it to be!

Replaced (simple line break by pressing enter)
with
[/Label]
[Label]

1 Like