1
123123 2013-07-30 17:46:00 +08:00
preg_match('~(\d+).html~', $url, $match);
去看看正则三十分钟 |
2
123123 2013-07-30 17:49:13 +08:00
更正上面正则中的「.」应该是「\.」,虽然结果没什么差
|
4
BeijingBaby 2013-07-30 17:50:48 +08:00
'|/(\d+)\.html|'
|
5
turing 2013-07-30 19:23:03 +08:00 1
lz 搞不清正则不放用语义化的正则包装:https://github.com/jehna/VerbalExpressions
|
6
lazygunner 2013-07-31 09:11:52 +08:00
import re
p = re.compile(r'^http://www\..*\.com/.*/(?P<num>\d*)\.html$') r = p.search('www.v2ex.com/t/123/html') r.group('num') |