【发布时间】:2015-12-16 16:41:49
【问题描述】:
import re
s = 'PythonCookbookListOfContents'
# the first line does not work
print re.split('(?<=[a-z])(?=[A-Z])', s )
# second line works well
print re.sub('(?<=[a-z])(?=[A-Z])', ' ', s)
# it should be ['Python', 'Cookbook', 'List', 'Of', 'Contents']
如何使用Python re从小写字符和大写字符的边框分割字符串?
为什么第一行不行而第二行行得通?
【问题讨论】: