How to remove whitespace and duplicates from an array

This message box shows the text which is to be inputed into an array:

image

I wanted to split by new line and save the split items as an array. To do this I made a new array:

new_arr = Text.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

When I printed the items of the new_arr I saw the split didn’t work properly as there was a lot of white space.

item1 = " [whitespace] "
item2 = " [whitespace]"
item3 = " [whitespace]"
item4 = " [whitespace]No results found"
item5 = " [whitespace]"
item6 = " [whitespace]Google Cloud Machine Learning platform"
item7 = " [whitespace]"
item8 = " [whitespace]Machine Learning"
etc

Is there a way to create a new array from this by deleting all the whitespace and only saving the text items of the array?

Hi Maggi,

Could you share the text file please

I’m scraping the data from a website and the website is proprietary

Hi Maggi,

Please check the attached xaml. Did slight modification. Hope it helps
RemoveWhiteSpacec.xaml (7.5 KB)

Content of sample text file:

No Results found

Google cloud machine learning platform

Machine Learning

Microsoft Azure machine learning

6 Likes

You can use String.Replace(" ", “”)

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