I have a problem with the symbols ^ and .
I need to replace all \ and ^ with \ and \^. But we don’t know which ones are present in the search string containing it .
The combination can be in any order .
if '\\'or '^' in Pattern:
Pattern = Pattern.replace("\\",r"\\")
Now i need to replace \ , ^ or both .Whichever is found .
If both are present , then both . Or if any one of them is found , then that one.
How do we replace conditionally , one , or all …?
You can replace without testing: