How to get a text after multiple spaces using string manipulation

Hi Guys!!

I have to get the text after spaces using string manipulation.

Ex : 01 UiPath Automation

In the above example, I have to extract all the three texts, but I don’t know how many spaces will be there between each text. How to achieve it. help me to resolve this.

Thanks in advance :smiley:

Hi @mohamedalthaf

Try the following

inputString= "01 UiPath Automation"
textArray= inputString.Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
For Each currentItem in textArray
   WriteLine-> currentItem.ToString
End For Each

textArray is of DataType Array(System.String)

Check the below workflow for better understanding

Output:
image

Hope it helps!!

1 Like

@Parvathy Thanks This is perfectly working.

I have a doubt. Hope you can help me

Ex : 01 Ui Path Automation

In the above example there is a single space between Ui & Path & multiple spaces between other texts. In this scenario I have to remove only the multiple spaces and have to get Ui Path text as it is without splitting. Is it possible?

Thanks for your help :blush:

Hi @mohamedalthaf

Try the following:

inputString= "01 UiPath Automation"
cleanedText = System.Text.RegularExpressions.Regex.Replace(inputString, "(Ui)\s*(Path)", "$1$2")

Hope it helps!!

If your input is like the following,
image

the follwoing expression will work.

System.Text.RegularExpressions.Regex.Split(yourString,"\s{2,}")

Regards,

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