Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lock_4815162342
Channel Surfer

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. 😄
0 Kudos
2 REPLIES 2
RokuMarkn
Visitor

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
Roku Guru

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.