Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I split a string into multiple stings?

I have a parsed string that I want to put into a paragraph screen. I want the string to have lines separated by newlines. I tried using \n but it is reading it as literal text.



Can I go through a string and check each character and split the lines based on a delimiter ?

Can I index a string to do so?

Thank you for your help. Smiley Very Happy
0 Kudos
2 Replies
RokuMarkn
Level 7

Re: How do I split a string into multiple stings?

You can use roRegex.Split to split a string on a delimiter.

You may also want to look at this code that splits a string based on length, but it's intended for, and may only work correctly with, roScreen.

--Mark
0 Kudos
EnTerr
Level 9

Re: How do I split a string into multiple stings?

Another way to split the string is to use roString.Tokenize(), like so:
BrightScript Debugger> nl = chr(10)
BrightScript Debugger> s = "1" + nl + nl + "2" + nl + "3"
BrightScript Debugger> ? s.tokenize(nl)
1
2
3
0 Kudos