Activity Forums Salesforce® Discussions How do I remove special characters from a string in Salesforce?

  • Shweta

    Member
    August 27, 2020 at 3:23 pm

    We can revome all the special charaters from the string in apex by using .replaceAll().
    example:
    string testString = 'Welcome - %% to !!@@* Sales ##force^&';
    testString = testString .replaceAll('[^a-zA-Z0-9\\s+]', '');

  • Pooja

    Member
    August 27, 2020 at 6:45 pm

    string testString = 'Welcome - %% to !!@@* Sales ##force^&';testString = testString .replaceAll('[^a-zA-Z0-9\\s+]', '');

  • Ayush

    Member
    August 28, 2020 at 6:31 am

    you can use removeAll() .

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos