December 29, 2019

How to remove all non numbers using Apex in Salesforce?

Sample code:


  1. String invalidNumbers = '[^0-9]';  
  2. String str = 'abcd123456789xyz';  
  3. system.debug( 'Only numbers - ' + str.replaceAll( invalidNumbers, '' ) );  

Output:


No comments:

Post a Comment