How to Remove Blank Lines from a string?

Hi Team,
I want to remove all the blank lines, and white spaces from the start and end of each line in a string.

Input String:
"1st Additional
Interest

					GREAT SOUTHERN BANK
					ISAOA/ATIMA
					
					
					PO BOX 3106
					
					
					 COPPELL, TX, 
						75019-XXX
				
				
					Loan Number:3026
				 

				
					
						Update
							Additional Interests"

Required Output String:
“1st Additional Interest
GREAT SOUTHERN BANK
ISAOA/ATIMA
PO BOX 3106
COPPELL, TX,
75019-XXX
Loan Number:3020
Update
Additional Interests”

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"^\s+","",System.Text.RegularExpressions.RegexOptions.Multiline)

Regards,

Hey Yoichi,
It worked.
Really appreciate it, Thanks!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.