【发布时间】:2012-05-28 16:36:09
【问题描述】:
我对 python 中的正则表达式很陌生。我有以下字符串,想将它们分成五类。我只是使用 split() 但它只会根据空格进行拆分。
s = "1 0 A10B 1/00 Description: This is description with spaces"
sp = s.split()
>>> sp
["1", "0", "A10B", "1/00", "Description:", "This", "is", "description", "with", "spaces"]
如何编写正则表达式使其像这样拆分:
["1", "0", "A10B", "1/00", "Description: This is description with spaces"]
有人可以帮忙吗?谢谢!
【问题讨论】:
-
感谢大家的回复!