Hi,
I want to remove all empty newline in the string.
Attached is my text that I want to remove the new line.
I’ve tried few method but all failed and does not change at all. I’m not sure why.
Try method 1
processDetail.Replace(Environment.NewLine+Environment.NewLine,Environment.NewLine)
Try method 2
System.Text.RegularExpressions.Regex.Replace(processDetail, “\n+”, “”)
EXAMPLE.txt (574 Bytes)
Yamatendo
(Constant Roux)
2
Hello, have you tried with vbNewLine instead of Environment.NewLine ?
As following : processDetail.Replace(vbNewLine+vbNewLine,vbNewLine)
Yoichi
(Yoichi)
3
Hi,
Can you try the following expression?
System.Text.RegularExpressions.Regex.Replace(strData,"(\r\n\s*){2,}","\r\n")
OR
System.Text.RegularExpressions.Regex.Replace(strData,"(\r\n[^\S\r\n]*){2,}","\r\n")
Regards,
I’ve tried with vbNewLine also not working.
It became like this .
There are few lines that combined together instead.
Yoichi
(Yoichi)
6
Hi,
Sorry, I had a mistake. Can you try the following?
System.Text.RegularExpressions.Regex.Replace(strData,"(\r\n[^\S\r\n]*){2,}",vbCrLf)
Regards,
1 Like
This one work!
Can I know is vbCrLf stands for new line ?
Yoichi
(Yoichi)
8
Hi,
Yes, vbCrLf is Chr(13)+Chr(10) : this is linebreak of WindowsOS.
Regards,
1 Like
Thank you for the resource and your help on this.
Appreciate it.
system
(system)
Closed
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.