var str = 'milk and @#$%&!bread'; gs.print(str.replace(/[^a-zA-Z0-9]/g, ''));
Output:
How to remove space and special character from String ServiceNow and JavaScript?
Working Code Asked question July 21, 2023
var str = 'milk and @#$%&!bread'; gs.print(str.replace(/[^a-zA-Z0-9]/g, ''));
Output: