Delete new line and unwanted space

Hi, everyone,

I need help with deleting lines. So the data I extracted from a txt file has value
“2019
February
25
"
With a lot more empty lines in between, so when I try to write back to excel, the column looks super large. I want it to be “2019 February 25”. I tried both Replace(”\n","") and Replace(Environment.NewLine, “”), they both not working. And I also tried Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries) , not working as well
image
image

1 Like

Try this and please update that it worked it not !!
StringVaraible.replace({vblf},"")

1 Like

image
hello, it is not working, and this is the error I got. @ syedabidraza

@jadepu2010

Use this

String.Join(Environment.NewLine,YourVariable.Split({Environment.NewLine,vbcrlf,vblf," ",vbtab,vbcr,vbNewLine},StringSplitOptions.RemoveEmptyEntries))

2 Likes

Try this
string = string.replace("/\s\s+/g","");

1 Like

Nope, it’s still "
2019
February
25
"

Nope, it’s still the same

Try this regex pattern
(?:\s*)(\w+)

1 Like

@jadepu2010

use this

3 Likes

@Vijay_Tulsalkar
Thanks it works

1 Like

Hi @Vijay_Tulsalkar
Nice string. Can you dissect it for us part by part to explain what it does?
I guess vb is some action. so you filter ctrl, lf?, tab, cr? and newline. Then remove all empty spaces?

1 Like

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