How to Remove Non-Numeric Characters From a String Using Apex in Salesforce

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

Posted By : Sudeer Kamat Date :

view_module Related

  • How to Mass Update Records In SalesforceHow to Mass Update Records In Salesforce
  • How to find whether apex Trigger Context is currently executed in Salesforce?How to find whether apex Trigger Context is currently executed in Salesforce?
  • How to Get The Week Number of Month From Date in Salesforce?How to Get The Week Number of Month From Date in Salesforce?
  • How To Find Day Of Week Using Apex?How To Find Day Of Week Using Apex?
  • How To Find Date Fields From Any Objects Using Apex In Salesforce?How To Find Date Fields From Any Objects Using Apex In Salesforce?

label Labels

Comments 0