OriginalPostID-174728
Discussion posts and replies are publicly visible
I would start by substituting all "new line" characters with a space; and then use trim() to remove all unnecessary spaces. So:
fn!trim( fn!substitute( ri!myString, char( 10 ), " " ) )
I just noticed the previous replies that reference use of char(13) alongside char(10)...so the principle remains the same, but you'd iterate over the string to substitute both with a space and then tidy it all up with trim():
fn!trim( fn!reduce( fn!substitute, ri!myString, {char(10),char(13)}, " " ) )
Obviously you can extend the list of characters to be excluded as needed..
It's hard to know exaclty what the original poster's use case was from over 4 years ago, but it seems to me that they didn't want to remove all newlines, just extraneous ones (seemingly only at the beginning or end of a string). I'm sure there's now a more graceful coding solution than the original one I posted so long ago, though it's always fun to see my name pop up in a newly-revived thread.