Problem in split a text into an Array

Hi Everyone, I hope you doing well!

I am facing a challenge while trying to split a variable named ‘StrExctractedText’ into an Array by splitting it with a newLine delimiter
image

that contains the following text:
image

I tried to use the split function but the result after Looping inside the Array is a single-element array instead of three elements as expected. as you see here:
image

After several tries, I changed the way to Regex, here:
image

and the output is a 5 Elements array instead of three elements also
image

Can anyone provide guidance on how to correctly split the ‘StrExctractedText’ variable into an array where each line is a separate element?

give a try at trimming
Assign Activity:
arrSplits | String Array =

YourTextVar.Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries).Select(Function (x) x.Trim())

You can prototype it within the immediate panel as well

1 Like

Hi,

Another approach:

It may be linebreak matter. Can you try the following expression?

StrExctractedText.Split(vbcrlf.ToCharArray,StringSplitOptions.RemoveEmptyEntries)

If you need to trim each item, @ppr 's LINQ expression will help you.

Regards,

1 Like

Hi @Islam_ISmail

Try the below following way:

StrExctractedText= "Client ID: BL17488
                    Client Name: Mabel Suttle
                    Client Country: Romania"

arrDetails= StrExctractedText.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)

Hope it helps!!

1 Like

SplitAndTrim.zip (2.7 KB)

Use this Workflow

1 Like

Use Split(yourstring,delimiter) instead of yourstring.Split because the former accepts a string instead of character array.

image

image

1 Like

Thank you for your response that helps me!

@Islam_ISmail
Perfect, so the topic can be closed

1 Like

Thank you for your response I’ll try this out !

Thank you for helping me out !!

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