How to remove all non numbers using Apex in Salesforce? December 30, 2019June 9, 2022InfallibleTechie Admin Sample code: String invalidNumbers = ‘[^0-9]’; String str = ‘abcd123456789xyz’; system.debug( ‘Only numbers – ‘ + str.replaceAll( invalidNumbers, ” ) ); Output: