I need to match the following pattern:
text1.cps.text2
text1.text2.cps.text3
cps.text1
where text1, text2 are some random words. cps is one of several possible words. So I wrote the following regexp:
pattern = "(\w+\.)*?({0})(\w+\.)*"
And than I iterate over list of possible words:
for word in ['cps.','cps.tbl.']:
p = pattern.format(word)
So the problem is that item from the possible words can contain special regex chars. So I am looking for function that replaces each special character into something like that:
cps\. and cps\.tbl\.