0
How to use code to remove extra information?
I have set up two text elements in the database, and text1 contains the following information.
2222
333
44553
1234
How to set up a button to remove the extra spaces in the content of text1? Only retain the following information in text2.
2222
333
44553
1234
(The spaces in each record are random.)
9 replies
-
You can try:
let xBreak := urlDecode("%0A"); "// Split the text into lines"; let lines := splitx('Text 2', "\n"); "// Filter out empty lines"; let nonEmptyLines := lines[!= ""]; "// Join the non-empty lines back together with newline characters"; let result := join(nonEmptyLines, xBreak); result
I tried out ChatGPT for Ninox and while it didn't give me the correct answer it did lead me down this path.
I go from:
2222 333 444 555
to:
2222 333 444 555
It suggested this:
function removeEmptyLines(text : text) do // Split the text into lines let lines := split(text, "\n"); // Filter out empty lines let nonEmptyLines := lines[!isempty(item(lines, i))]; // Join the non-empty lines back together with newline characters let result := join(nonEmptyLines, "\n"); result end;
which didn't work. Line 3 should be splitx() not split(). Line 5, the editor didn't like it. Line 7 inserts the text "\n" and not the actual new line.
-
said:
I tried outJacques TUR ChatGPT for NinoxI also tried it! Haha, thank you for Fred's help.
-
let cr := " "; join(split('Text 2', cr)[!= ""], cr)
-
replacex('Text 2', "\n+", " ")
Content aside
- Status Answered
- 4 mths agoLast active
- 9Replies
- 75Views
-
4
Following