Forum Discussion

lock_4815162342's avatar
lock_4815162342
Channel Surfer
11 years ago

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. 😄

2 Replies

  • 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
  • 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