用python(V1.0)如何匹配HTML标签的实际操作
用python(V1.0)如何匹配HTML标签的实际操作
下的文章就是对pythonV1.0)在实际相关应用方案的具体应用,如果你对pythonV1.0)在匹配HTML标签的具体应用方案的具体介绍,如果你对其感兴趣的话,你就可以点击我们的文章。
匹配HTML标签
- #coding:utf-8
- import re
- nStr = "<div>"
- p = re.compile('</?\w+[^>]*>',re.I)
- if p.match(nStr):
- print "exists"
输出
- else:
- print "not"
URL相关匹配EMAIL地址
- import re
- nStr = "hkebao@126.com"
- p = re.compile('^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$',re.S)
- if p.match(nStr):
- print "exists"
- else:
- print "not"
pythonV1.0) 匹配URL
- import re
- nStr = "http://localhost"
- p = re.compile('^[a-zA-z]+://(\w+(-\w+)*)
(\.(\w+(-\w+)*))*(\?\S*)?$',re.S)- if p.match(nStr):
- print "exists"
- else:
- print "not"
以上的文章就是对pythonV1.0 匹配HTML标签与匹配URL的实际相关应用方案的介绍。
热门文章:
相关内容
- 暂无相关文章
评论关闭