我正在尝试制作一个简单的函数来分割数字和alpha,
e.g: &#34;日期:16.06.2016开始时间(带时区):2:30pm 至 4:00Pm 结束时间(带时区)&#34; < / p>
代码后: &#34;日期:16.06.2016开始时间(带时区):下午2:30 到 4:00 Pm 结束时间(带时区)&#34 ;
enter code here
x="Date : 16.06.2016 Start Time (with time zone) :2:30pm to 4:00Pm End Time (with time zone)"
p = re.compile("([0-9])([([a-z])")
for m in p.findall(x):
print (m)
答案 0 :(得分:0)
您可以使用:
import re
y=re.sub("(?<=[a-zA-Z])(?=[0-9])|(?<=[0-9])(?=[a-zA-Z])", " ", x)
z=re.sub("(?<=\s):(?=[0-9])", " : ", y)