用python(V1.0)如何匹配HTML标签的实际操作

开发 后端
python作为计算机语言中被广泛应用的脚本语言,已被大家了解。但是你对python(V1.0)的实际相关应用是否了解呢?以下就是文章的具体介绍。

下的文章就是对python(V1.0)在实际相关应用方案的具体应用,如果你对python(V1.0)在匹配HTML标签的具体应用方案的具体介绍,如果你对其感兴趣的话,你就可以点击我们的文章。

  匹配HTML标签

 

  1. #coding:utf-8  
  2. import re  
  3. nStr = "<div>" 
  4. p = re.compile('</?\w+[^>]*>',re.I)  
  5. if p.match(nStr):  
  6. print "exists"   

输出

 

  1. else:  
  2. print "not"  
  3.  

 

URL相关匹配EMAIL地址

 

  1. import re  
  2. nStr = "hkebao@126.com" 
  3. p = re.compile('^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$',re.S)  
  4. if p.match(nStr):  
  5. print "exists"  
  6. else:  
  7. print "not"  
  8.  

 

 

python(V1.0) 匹配URL

 

  1. import re  
  2. nStr = "http://localhost" 
  3. p = re.compile('^[a-zA-z]+://(\w+(-\w+)*)
    (\.(\w+(-\w+)*))*(\?\S*)?$',re.S)  
  4. if p.match(nStr):  
  5. print "exists"  
  6. else:  
  7. print "not"  

 

 

以上的文章就是对python(V1.0 匹配HTML标签与匹配URL的实际相关应用方案的介绍。

【编辑推荐】

  1. Python复制文件的实际操作方案与代码详解
  2. Python矩阵转置中的二维数组的实际操作方案介绍
  3. Python socket编程在具体应用中前两个步骤的介绍
  4. Python Library中Condition的具体操作方案
  5. 在Python Library中Event具体实际操作方案

 

 

责任编辑:佚名 来源: 博客园
相关推荐

2010-03-15 16:54:11

Python字典

2010-03-26 08:46:29

Python 2.5.

2010-03-09 18:55:27

Python djan

2010-03-10 19:00:20

Pythonnext函

2009-08-26 16:37:04

ibmdwRational

2010-03-12 15:29:19

Pythonexe

2010-05-10 10:19:28

Oracle实战RMA

2010-03-25 17:28:41

Python配置

2010-03-16 12:39:09

python for

2010-06-01 15:54:46

MySQL-pytho

2010-03-23 16:30:47

Python文件复制

2010-03-05 15:07:35

Python优化图片

2010-07-02 11:10:56

SQL Server

2010-04-20 11:06:33

Oracle索引

2010-04-01 14:06:13

Oracle Name

2010-03-09 09:32:20

Python网页爬虫

2010-03-23 16:52:42

Python分解路径名

2010-03-31 16:11:00

Oracle启动

2010-05-18 17:39:13

MySQL alter

2010-04-14 17:06:41

Oracle安装路径
点赞
收藏

51CTO技术栈公众号