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

outlook
studio
string

#1

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


#2

Hi @chenghai0208,

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


#3

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


Want to extract relevant information below regards in the mail signature
#4

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


Remove the break lines
#5

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

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


#6

Hi @chenghai0208,

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


#7

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.


#8

thanks @akila93

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


#9

@Dominic

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


#10

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


#11

thank you. Just what I needed


#12