We are trying to do a replacement of String in code particular for masking. In the code, we want to use replaceFirst to replace the first match. But instead of using regex, we want to use the actual string, something like below:
input = input.replaceFirst(stringToMask, masked);
This works in most situations, but in cases where the input string has a () in it, Salesforce will consider the input string to be a regex and try to resolve it will most probably cause an exception.
Is there a way we can escape the string here to make it to treat it as an normal string here? Otherwise we might need to go through the indexOf and subString() path.