function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Test Test 143Test Test 143 

how to remove extra line space between two lines in Salesforce Apex?

Hi All,
I have long text area field and which has data in multiple lines. My requirement is to remove extra line space between lines. Please help me on this.

Example : 
Data in the long text area field : 
"abbbccbb


hghgdghdfhgirtufgjhfhkf

hhfjkkbbhvkhbjkhbkjchjb"


I need to remove extra line space between lines. We should have only one line space between lines.

Thanks!
 
VinayVinay (Salesforce Developers) 
Hi Test,

You can try something like below.
String.valueOf(t.fieldname).replace('\n', '').replace('\r', '');
Please mark as Best Answer if above information was helpful.

Thanks,