function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VINODKUMAR REDDY KALUVAVINODKUMAR REDDY KALUVA 

How to remove Special Characters without removing Chinese Characters from the String

I'm looking out to remove all the special characters from the string without removing Chinese or any other langaguge characters in Apex.

String strText = 'Welcome - to! % $sale&sforcecode # crack %  东莞可达薄有限公司';

Excepted O/P : Welcometosalesforcecodecrack东莞市可达薄膜科技有限公司
 


I don't want to use for loop, any regex compartiable for apex?

Dushyant SonwarDushyant Sonwar

Use this regex

System.debug('Welcome - to! % $sale&sforcecode # crack %  东莞可达薄有限公司'.replaceAll('[^a-zA-Z0-9\u4e00-\u9fa5]', ''));

It will give you the expected output

Excepted O/P : Welcometosalesforcecodecrack东莞市可达薄膜科技有限公司

Hope this helps!