Gradle task to replace string with special characters

I’m trying to write a task to replace a string in a file and replace it. Although I found the replaceAll operation, I’m unable to do so as the string I want to replace contains special characters like /, ’ and %.
Any help is much appreciated.

You should provide some examples for the strings you want to be replaced, wich parts of those strings should be replaced by which characters and the regular expression your are having currently. Maybe it’s even a good idea to provide the complete task.