How can we split string where we get empty line

How can we split string where we get one or more empty lines in a string,
msgbox

1 Like

text.Split({System.Environment.Newline},System.StringSplitOptions.RemoveEmptyEntries)
This will split with new line and empty space will be ignored

its not working

My mistake, Try this :sweat_smile: text.Split(System.Environment.Newline,System.StringSplitOptions.RemoveEmptyEntries)

Or

Text.split(" “,”") :slight_smile:

and a screen shot of what you are getting after this

Hi @Mohsin_Inamdar,

Try this

txtStr.Split(New String() { Environment.NewLine + Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
1 Like

@Mohsin_Inamdar,
I recently publish custom activity to make life easy. You may want to use it. Its very straightforward.

Example:

Let me know if you need assistance or if you are still facing issue.
Cheers

1 Like

Whats the solution for this

Hi @Rachel7

Try this

InputString.ReplaceLineEndings(" ")

Regards,

@lrtetala

My input is
"testing split
function

using UiPath"

and I want the output in array as
array(0)-testing split
function

array(1)-using UiPath

@Rachel7

to split by new line below code works,
yourstring.Split(System.Environment.Newline,System.StringSplitOptions.RemoveEmptyEntries)

you can refer to the uploaded file if you want to split only by empty newlines
I haves used regex to split
System.Text.RegularExpressions.Regex.Split(txtStr,“\n{2,}”)
Hope that helps
StringSplit.zip (2.9 KB)