[英]Python Regex that adds space after dot
How can I use re
to write a regex in Python that finds the pattern: 我如何使用
re
在Python中编写一个找到该模式的正则表达式:
dot "."
点“。” followed directly by any char [a-zA-Z] (not space or digit)
直接跟随任何char [a-zA-Z](不是空格或数字)
and then add a space between the dot and the char? 然后在点和char之间添加一个空格?
ie 即
str="Thanks.Bob"
newsttr="Thanks. Bob"
Thanks in advance, Zvi 谢谢,Zvi
re.sub(r'\\.([a-zA-Z])', r'. \\1', oldstr)
re.sub('(?<=\.)(?=[a-zA-Z])', ' ', str)
尝试
re.sub(r"\.([a-zA-Z])", ". \\1", "Thanks.Bob")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.