I write on a function that replaces strings but in one part it should replace a text as it is without regular expressions.
In some cases there are regular expressions in it but I want that they are not seen as one.
For example str_replace("0.5 (p-value = 0.04)", "(p-value = 0.04)", "foo") leads to "0.5 (foo)" because of the regex-meanings of ( and ). My desired result is "0.5 foo", I want them to be seen as they are.
I know, I can use str_replace("0.5 (p-value = 0.04)", "\\(p-value = 0.04\\)", "foo") but I want a general solutions for all other regular expressions like ^, $, ?, . ...
Is there an easy function for this?