【发布时间】:2016-07-04 01:40:38
【问题描述】:
我有一个非常长且可变的字符串。 像这样:
s = "hello today we see there? Otherwise are available tuesday 10:00 to 18:00. OK?"
或者这个:
s = "hello today we see there? Otherwise are available tue 10.00 to 18.00. OK?"
我想作为输出:
tuesday 10:00 to 18:00
或者:
tue 10.00 to 18.00
我试过了:
print re.findall("(tuesday|tue \s\d+:|.\d+\s-\s\d+:|.\d+)",s)[0]
但它不正确。
【问题讨论】:
-
你实际上没有可变字符串,因为 Python 字符串是不可变的。
标签: python regex string findall