As you probably all know, regular expressions have some metacharacters, such as \, |, ., ?, +, *,…. If you want to search for a substring including one of these characters without actually using the regex behaviour, you can escape it with a backslash.
So if you want to search for "Is it true?" in a string you would use the pattern
"Is it true\?".
I am using Kotlin and its built-in regular expressions. Is there a way in Kotlin (a function or something) to get a string from another string in which all of the special characters in the input string are escaped?
So if the input to such a function were "This is good." the output would be "This is good\.", and for "? a [+" it would be "\? a \[\+". → every regex special character in the output is escaped with a backslash.