I am looking for something like trim (), but within a string. Users sometimes put 2, 3, 4 or more lines after they print, I need to sanitize this entry.
Input example
i like cats
my cat is happy
i love my cat
hope you have a nice day
Required conclusion
i like cats
my cat is happy
i love my cat
hope you have a nice day
I don't see anything inline, and replacing a string will require many iterations to do the job. Before I pick up a small recursive line, I want to see what other suggestions you had.
I have a strange feeling that there is a regular expression for this.
scott
source
share