Showing posts with label Special characters. Show all posts
Showing posts with label Special characters. Show all posts

Wednesday, December 26, 2018

How to remove all special characters from String in Apex

This post explains how to remove special characters from the string in Apex
Example:
String strText = 'Welcome - to! % $sale&sforce \\ /code # crack %';
strText = strText.replaceAll('[^a-zA-Z0-9\\s+]', '');
System.debug('strText ======> '+strText);

Result
Happy Learning!!!