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
Rolando EstevesRolando Esteves 

String [] split function

 

I was able to upload records into objects with a custom code in apex. My only problem is that the split function does not care about text delimiters. Is there any possible way to be able to split without afecting fields with commas inside a text delimiter.

 

Example : "DOG HAS , A HOUSE"

 

Example Code:

 

          String FileData = FileRecords.toString();
           FileData = FileData.replace('"', '');
     
           if(FileData <> NULL)
           {
              LineNo = FileData.split('\n');

 

Bhawani SharmaBhawani Sharma
1. Split first by \r\n. - You will get records data
2. Remove first and last double quote. rowData.substring(1, rowData.length() - 1);
3. Split row by rowData.split('","', ''); - You will get fields data
Rolando EstevesRolando Esteves

Imagine a record like this:

 

"ALPHANUMERIC , NUMERIC" , Dog, Cat , Chicken

 

Any ideas?