Remove line breaks in string

Hi, sometimes I get a string that has a line break, e.g.:
XyzVar=“string starts here
but should continue on same line”
How can I remove any line break that might occur?
Thanks

7 Likes

Hi @Jizh

Edited:

Better one is this

stringResult= Regex.Replace(yourString, "\t|\n|\r", "")

Or you can try

StringResult = String.Replace(Environment.newLine,"")

Thanks,
Prankur

14 Likes

Hi @Jizh

XyzVar = XyzVar.replace(VbCrLf,"")

Regards,
Reda

3 Likes

Thank you. @PrankurJoshi Why is the first one better?

I think if you do it with regex then its better that’s it nothing else :slight_smile:

Okay, thanks for the reply :slight_smile:

1 Like

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