python正则表达式模块re中search和match方法的区别
2017-12-18 10:06
1001 查看
re.
search(pattern, string, flags=0)¶
Scan through string looking for the first location where the regular expression pattern produces a match, and return a corresponding
MatchObjectinstance.
Return
Noneif no position in the string matches the pattern; note that this is different from finding a zero-length
match at some point in the string.
re.
match(pattern, string, flags=0)
If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding
MatchObjectinstance.
Return
Noneif the string does not match the pattern; note that this is different from a zero-length match.
For example:
>>> re.match("c", "abcdef") # No match >>> re.search("c", "abcdef") # Match
https://docs.python.org/2/library/re.html#search-vs-match
相关文章推荐
- python 正则表达式精华 re.match与re.search的区别
- python 正则表达式注意事项和re.match()和re.search()区别
- [python][正则表达式] re模块核心函数和方法
- [Python] re(正则表达式) 模块使用方法
- python re模块search()与match()区别
- Python 正则表达式 RE模块的使用方法
- 正则表达式之re.search()与re.match()用法区别
- python的正则表达式re模块的常用方法
- python学习:python中的正则表达式函数match和search()的区别
- 3分钟内理解Python的re模块中match、search、findall、finditer的区别
- Python 正则表达式 RE模块的使用方法
- python的正则表达式re模块的常用方法
- python re.search 和 re.match 正则表达式
- python的正则表达式re模块的常用方法
- python 正则表达式 re模块常用方法
- Python高级——正则表达式 re模块1.match方法
- Python RE模块中search()和match()的区别
- python re.search 和 re.match 正则表达式
- [整理] python的正则表达式re模块的常用方法
- Python中正则表达式match()、search()函数及match()和search()的区别详解