We need to remove the all special character from the string in apex.
String s1 = 'a"b*c:5>x<y?z/de|f\'';
String regExp = '"*:<>?\/|\/‘;
String replacement = '1';
String s2 = s1.replaceAll(regExp, replacement);
System.debug(s2);
Above code shows,
Illegal string literal: Invalid string literal
'"*:<>\/?|'
. Illegal character sequence\/'
in string literal error.
How to remove the special character from the string in apex.