Replacing special characters with underscore in apex or trigger.I am using below things but getting error.
string groupname=(gr.name).replace(/[^A-Z0-9]+/ig, '_');
Error: expecting a right parentheses, found '/'
But working in javascript and java but not in apex trigger.
For testing i have used below code snippets
String abc = 'SVP, Customer Service & Support group';
string groupname=abc.replace('/[^A-Z0-9]+/ig', '_');
System.debug('value of string :::: '+groupname);
But it returned me below : SVP, Customer Service & Support group but i want to be returned like SVP_Customer_Service___Support_group
replace(..)
has to be an apex string