I need to replace dots within brackets with re
with another string:
from
a = 'hello.mate(how.are.you)'
to
b = 'hello.mate(how|DOT|are|DOT|you)
I tried to use /(
to highlight the beginning of the brackets and /)
for the closing, but I am unclear how to capture the simple dot in between.
The two most pertinent examples
These two questions clearly faced the exact same problem, expecially question #2, but I can't seem to capture just a single dot in the re.sub
Regex replace text between delimiters in python
Regex using Python to replace dot of floating numbers with "dot"
Attempted solutions
Various ineffective attempts based on the examples above include:
b = re.sub(r'\(.\)','|DOT|', a)
b = re.sub(r'\(\.\)','|DOT|', a)
b = re.sub(r'\([.]\)','|DOT|', a)
b = re.sub(r'\([\.]\)','|DOT|', a)