How to loop through lists and split which has more than 2 or more spaces


1). first im storing entire pdf data by row wise in a form of List( of string)
2). then i’ve to get each row and split/remove spaces,i’ve got this result when i pass single row outside the loop, when i try it inside the for each im not able to get the result

ERROR:" Unable to cast object of type ‘System.Char’ to type ‘System.String’."

tried different approach and got error like “System.string

thank you


Just try with this linq query in an Assign activity.

Pass this in the right side of the assign activity and assign it to “yourListString” list(of String) in the left side.

yourListString.[Select](Function(t) System.Text.RegularExpressions.Regex.Replace(t, "\s+", "")).ToList()

it’s just displaying the Variable Type

ClearSpaceInList.xaml (5.9 KB)

Check this xaml, it is working for me without any issues.

i’ve to split only which has more than 2 spaces

ClearSpaceInList.xaml (8.1 KB)

Updated workflow as per the need, it has both functionalities, check and comment the unwanted one as per your need.

Sequence.xaml (7.4 KB)

see this file i’ve to iterate each row and split the spaces PDF1.pdf (307.9 KB)

1 Like

in Assign “Value” i’m getting particular row but i dont want to do that
ive to do in loop

any idea how to solve it???


Do you want to split the PDF into each line and check for the double spaces to elimate?


Sequence.xaml (11.5 KB)

Check this one.

as you can see i’m getting the entire row which i dont want
if there is single space i want that whole thing as “Demo - slice invoices” after this there are more spaces so i need the next element “order number” and “12345”

you are replacing can we just split??

only delete the more spaces and iterate through all and get values

is it possible??


System.Text.RegularExpressions.Regex.split(YourInputString, “\s{2,}”)

1 Like

done this , its displaying as “system.string

May I know where did you kept this code

You supposed to kept in for each
And for each arugment value is string in property pannel

for each itself…