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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Split a string with 140K lines

Hello Roku Team,

I have a response HTTP that returns a txt file with 1.3MB and 140k lines.
I would like split the string in an array. I'm using the follow regex: 

text = searchRequest.getToString()
reLineSplit = CreateObject ("roRegex", "(?>\r\n|[\r\n])", "")

for each line in reLineSplit.Split (text)
end for
But, it's taking time to run.
Do you have a suggestion for me?

Thanks in advance.
0 Kudos
Roku Employee
Roku Employee

Re: Split a string with 140K lines

That seems like an excessive amount of data to be working with. 
Can you pass some filters to your web request to get just the data actually needed for the displayed content or business logic?
Or use a windowed query to just download small portions of the data at a time?

Aside from that, if you do just:

for each line in text.Split(Chr(13) + Chr(10))
    ' do something with line
end for

I would expect that to be orders of magnitude faster than using roRegex.

0 Kudos