Get the exact word array or list

Hi

I need help in extracting only words into a list or array from a multi-line string.
My input example looks as follows:

This is test string
Second Line String
Third line string

I can have multiple spaces if I split on the basis of space the extra space is being considered as a character which not a desired for me. Following is the expected output

Output:
This
is
a
test
string
Second
Line
String
Third
Line
String

I tried regex.replace(input,“\s*[2,]”," "). This is not replacing my input string extra spaces.

Any regex that can replace 2 or more spaces with a single space can work or a LINQ that gives me only words eliminating extra spaces can help.

@Babjee.Vangipurapu

Try this approach using assign activity

stringarraytWordList=inputString.Split(New String() {Environment.NewLine, " "}, StringSplitOptions.RemoveEmptyEntries)

This Regex should work to remove extra spaces.

System.Text.RegularExpressions.Regex.Replace(inputString, "\s+", " ").Trim()

Hi @Babjee.Vangipurapu
you can convert the list/array to string by join method. By this way you will have only one line of string and then you can break the line of string to desired output and while splitting it based on whitespaces. just apply for each to remove the leading and trailing whitespaces by using Trim method.

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