How to Remove Non-Numeric Characters From a String Using Apex in Salesforce
In this blog, you will learn how you can remove non-numeric characters from a string variable using apex in salesforce.
replaceAll() method can be used to remove non-numeric present in a string variable.
Follow below simple steps
- Go to Setup
- Open Developer Console
- Go To Debug menu
- Select Open Execute Anonymous Window from dropdown
String inputString= 'abcABCxyzXYZ!@1#2$3%^4&*()5_+';
String outputString = inputString.replaceAll( '[^0-9]', '' );
System.debug('Output String: ' + outputString );
- Click on Execute
Follow Us