How to remove Emojis from String using Salesforce Apex?

How to remove Emojis from String using Salesforce Apex?

Sample Code:

String tempStr = 'Testing @ 😗 😐 Sample % 😀 😁 😂 🤣 ⛑ ☕️ ☁️ 🥰 Example';
System.debug( 'Text wtih Emojis: ' + tempStr );
String strRegex = '[^\\p{L}\\p{N}\\p{P}\\p{Z}]';
String str = tempStr.replaceAll( strRegex, '' );
System.debug( 'Text without Emojis: ' + str );

Output:

Leave a Reply