学习一段python正則表達式了, 对match、search、findall、finditer等函数作一小结 以下以一段网页为例,用python正則表達式作一个范例: strHtml = '''<div> <a href="/user/student/" class="user-t"><img s ...
分类:
编程语言 时间:
2017-07-12 12:14:52
阅读次数:
150
python2和python3都有两种字符串类型strbytes re模块find一类的函数都是精确查找。字符串是模糊匹配 findall(pattern,string,flags) replace函数'hello python'.replace('p','P')'hello Python' a=' ...
分类:
编程语言 时间:
2017-07-04 23:15:24
阅读次数:
238
python2和python3都有两种字符串类型strbytes re模块find一类的函数都是精确查找。字符串是模糊匹配 findall(pattern,string,flags) replace函数'hello python'.replace('p','P')'hello Python' a=' ...
分类:
编程语言 时间:
2017-07-04 16:08:15
阅读次数:
258
大纲可参考博客:http://www.cnblogs.com/yuanchenqi/articles/6766020.html 1.正则表达式中(re模块),. 代表除换行符以外的任意符号,但如果加上re.S 则可以匹配所有符号。 import re ret=re.findall("c.d","ab ...
分类:
编程语言 时间:
2017-07-02 19:07:30
阅读次数:
158
beautifulsoup中的find和findall参数 findAll(tag,attributes,recursive,text,limit,keywords) findAll(tag,attributes,recursive,text,keywords) 分别代表,标签,传入字典形式的标签属 ...
分类:
其他好文 时间:
2017-07-01 21:43:34
阅读次数:
195
1.Mybatis中的接口形式 在Mybatis中使用接口形式将通过代理对象调用方法,从而实现sql的执行 1)定义一个接口 2)是通过代理对象调用方法 3)映射配置文件中,namespace的值是包名.接口名-->mapper.UserMapper 写sql标签的id为方法名 > findAll ...
分类:
其他好文 时间:
2017-06-30 01:10:22
阅读次数:
232
import re def repeat_func(s): #去掉重复的+——号 repeat = re.findall('\+\-|\-\-|\++\-\+', s) if len(repeat) > 0: for i in repeat: if i == '--' or i == '++': s... ...
分类:
其他好文 时间:
2017-06-29 22:35:45
阅读次数:
238
先po代码 代码分析: 1.re.findall语法: findall(parttern,string,flags=0) 含义:返回string中与partten匹配的全部字符串,返回形式是数组 2.find()语法:find(str,pos_start,pos_end) 含义:在url中查找str ...
分类:
编程语言 时间:
2017-06-28 11:52:45
阅读次数:
150
一 补充正则表达式的其他一些使用方法 1.贪婪模式:在满足匹配时,匹配尽可能长的字符串,默认情况下,采用贪婪匹配 2非贪婪匹配:在满足匹配时,匹配尽可能短的字符串,使用?来表示非贪婪匹配 3 .*?的用法: 4 re.findall 注意: findall的优先级查询: 5 re.split 注意 ...
分类:
其他好文 时间:
2017-06-27 18:35:44
阅读次数:
155
课堂# 取数字和普通字符import re# ret=re.findall("\w+","yuan123$888^%")# print(ret)# # ['yuan123', '888']# #取i# ret=re.findall(r"i\b","wo i ni")# print(ret)# # [ ...
分类:
其他好文 时间:
2017-06-27 16:23:12
阅读次数:
166