Just use String#replace(CharSequence target, CharSequence replacement) in your case to replace the given CharSequence as follows:
special = special.replace("@$", "as");
Or use Pattern.quote(String s) to convert your String to a literal String , as shown below:
special = special.replaceAll(Pattern.quote("@$"), "as");
If you intend to do this very often, consider reusing the appropriate instance of the Pattern (the Pattern class is thread safe, which means you can exchange instances of this class) to avoid compiling your regular expression on every call that has a deadline price.
So your code could be:
private static final Pattern PATTERN = Pattern.compile("@$", Pattern.LITERAL); ... special = PATTERN.matcher(special).replaceAll("as");
source share