Activity Forums Salesforce® Discussions How to split a string by comma and single quotation mark in apex?

  • Ravi

    Member
    May 25, 2016 at 6:45 am

    Hi Himanshu,

    Try with this

    First remove all single quotes and then split by comma

    String str = '\'First Name\',\'Last Name\',\'Account Name\',\'Email\',\'Title\',\'Description\'';
    System.debug('===str==='+str);
    for(String strFinal: str.replace('\'', '').split(','))
    {
    System.debug('===Final val==='+strFinal);
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos