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 Trigger Custom Notification Using Apex In Salesforce?How To Trigger Custom Notification Using Apex In Salesforce?
  • How to Run Assignment Rules During Insert or Update Operation Using Apex In Salesforce?How to Run Assignment Rules During Insert or Update Operation Using Apex In Salesforce?
  • How to Lock or Unlock a Record Using Apex In Salesforce?How to Lock or Unlock a Record Using Apex In Salesforce?
  • How To Find Fields That Are Part Of Page Layout In Salesforce?How To Find Fields That Are Part Of Page Layout In Salesforce?
  • How to Get Org Limit for Daily Maximum Apex Test Classes in SalesforceHow to Get Org Limit for Daily Maximum Apex Test Classes in Salesforce

label Labels

Comments 0