How to remove next line or new line char from last character onwards in any text string

Certified Associate Developer

We have test like below

" Need modification.

Remove last line

"

In this example, we just need to remove next line char after remove last line string. We still need to keep next line after Need modification.

We are generating some documents and formatting should not change if users has entered next line in between the lines but only last line should be removed as soon as Users entered Save.

trim will not work here as it will remove from all the text

  Discussion posts and replies are publicly visible