Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

Thursday, September 3, 2020

Remove spaces from a string using apex in Salesforce

Use the deleteWhitespace() to remove spaces from a string in Salesforce.

Ex:

String str = 'Salesforce Code Crack';
system.debug(str.deleteWhitespace());
Output


Wednesday, December 26, 2018

How to remove all special characters from String in Apex

This post explains how to remove special characters from the string in Apex
Example:
String strText = 'Welcome - to! % $sale&sforce \\ /code # crack %';
strText = strText.replaceAll('[^a-zA-Z0-9\\s+]', '');
System.debug('strText ======> '+strText);

Result
Happy Learning!!!