How to split text by newline code "/n"?

How to split text by newline code “/n” ?

6 Likes

Hi @chenghai0208,

Split string activity can be used to split.
Separator as System.environment.newline

Thansk @SaranyaKishore
It works when the newline code is “\r\n”
But not work in the text use newline code “\n”

Hi @chenghai0208,

Use anyone of them as a delimeter

vbCrLf - when you have both carriage return(Cr) and Line feed(Lf) in the string
vbCr - Only when Carriage return(Cr) in the string
vbLf - Only when Line feed(Lf) in the string

Reference : vb Constants

8 Likes

Thanks @Dominic
I don`t konw how to use them in uipath

↓↓↓ It don`t work
text.Split({“vbCrLf”},StringSplitOptions.none)

Hi @chenghai0208,

text.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries)

26 Likes

Syntax for Split,

InputStringVariable.Split("delimeter"c) OR
InputStringVariable.Split({delimeter1,delimeter2},StringSplitOptions.RemoveEmptyEntries)

Snippet:

str.Split(CChar(vblf)) OR
str.Split({vbLf},StringSplitOptions.RemoveEmptyEntries)

Where CChar - Explicit Conversion from string to Char datatype.

23 Likes

thanks @akila93

Environment.NewLine works when the newline code is “\r\n” but not “\n”.

1 Like

@Dominic

It works!!!
Thank U so much!!!

1 Like

Hi @chenghai0208 - Could you please upload the sample yaml file for reference.I tried the options mentioned, but receiving error.

thank you. Just what I needed