How to split a sentence in individual words and loop over them

I need to write a program which splits up a string of words into individual words and loop over them. The ammount of words is unknown.

Thank you very much.

1 Like

@Oscar_Schyns

Split the sentence based on space as delimiter.

varString.split(" ".C) - It will give array of String as the result.

2 Likes

Hi,

You can use the varString.ToCharArray() to convert the string to an array of characters.It will break the entire string to an array of characters.

–in an assign activity take one variable of type array of strings and use this syntax

string.split(" ".ToCharArray).toarray()  -- this will give array

Hi,
You can split the string based on the space or any other delimiter you are using in the string(Ex- comma,etc…).
stringName.split(" "c) for space
stringName.split(","c) for comma
This will return an array of words and you can loop through the array using For Each loop,

If you find this useful mark it as solution.
Cheers:smiley:

1 Like