我在努力获得价值
l1 = [u'/worldcup/archive/southafrica2010/index.html', u'/worldcup/archive/germany2006/index.html', u'/worldcup/archive/edition=4395/index.html', u'/worldcup/archive/edition=1013/index.html', u'/worldcup/archive/edition=84/index.html', u'/worldcup/archive/edition=76/index.html', u'/worldcup/archive/edition=68/index.html', u'/worldcup/archive/edition=59/index.html', u'/worldcup/archive/edition=50/index.html', u'/worldcup/archive/edition=39/index.html', u'/worldcup/archive/edition=32/index.html', u'/worldcup/archive/edition=26/index.html', u'/worldcup/archive/edition=21/index.html', u'/worldcup/archive/edition=15/index.html', u'/worldcup/archive/edition=9/index.html', u'/worldcup/archive/edition=7/index.html', u'/worldcup/archive/edition=5/index.html', u'/worldcup/archive/edition=3/index.html', u'/worldcup/archive/edition=1/index.html']
我试着从下面这样的东西开始做正则表达式
m = re.search(r"\d+", l)
print m.group()
但我希望值介于“archive/”和/索引.html“
我目不转睛地看了看,试过(?<=archive/\/index.html).*(?=\/index.html:)
但这对我没用。。我怎样才能得到我的结果列表
result = ['germany2006','edition=4395','edition=1013' , ...]
如果你确定模式总是匹配的,你可以使用这个
或者你可以这样分开
正则表达式
可以解决这个问题,假设
s
是列表中的一个字符串。你知道吗你需要四处看看。你需要这样使用它:
相关问题 更多 >
编程相关推荐