How to split a string and put it into a UMG?

For example, I have a string with 20 words length. I set a text widget in UMG and I want to show 10 words in a line and show the rest in another line. I know there is a function in STRING named “Split” but I don’t know how to use it to set the length limitation of each line. Can anyone help me? .)

You’re on the right track, there’s two ways I can think of to make this happen.

116770-capture.png

The Split string function allows you to cut a string into a left and a right value based off of a delimiter. For instance, if your string contains the following: “This is left - this is right” and you choose to Split it with the - delimiter, your Left S will be “This is left” while your Right S will be “this is right”.

This method is only useful if you will always have the same number of words so that your left and right are always equal (because you wanted 10 words each). So your values can only ever contain 20 words with one delimiter character. Kind of wasteful and not ideal, especially if you want something dynamic.

The Parse function will be your best option due to its flexibility. With parse, you can have a string variable that contains as many words as you wish, simply make the Delimiter a space. For instance, if you used the same example string as above “This is left - this is right” and passed it to the Parse Into Array with the space delimiter, you would get an array of string[7]. Where string[0] is This and string[6] is right. You can then go through a loop and use each word individually, maybe adding it to the widget in sequential order, the sky is the limit :slight_smile: