function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kunal Parmar 9Kunal Parmar 9 

Overcoming regex limits

I am trying to parse a file uploaded in my org. I am using String.split('\\n'); to split the string so that it gives me a list of strings each individual element having one line of my parsed file. The code works fine with small files. But, my application needs to work with large files, mostly 5000+ lines. I get a "Regex too complicated" error when using my application with large files. Can someone suggest a work-around for this error. Thanks!

The code is as below,
Blob b = document.body;
String content = b.toString();
parts = content.split('\\n', -2);
System.debug(parts);

where document is my uploaded file.