Python Regex that adds space after dot
How can I use re
to write a regex in Python that finds the pattern:
dot "." followed directly by any char [a-zA-Z] (not space or digit)
and then add a space between the dot and the char?
i.e.
str="Than开发者_运维问答ks.Bob"
newsttr="Thanks. Bob"
Thanks in advance, Zvi
re.sub(r'\.([a-zA-Z])', r'. \1', oldstr)
re.sub('(?<=\.)(?=[a-zA-Z])', ' ', str)
Try
re.sub(r"\.([a-zA-Z])", ". \\1", "Thanks.Bob")
精彩评论