1 / 11
文档名称:

python正则表达式re模块.docx

格式:docx   大小:30KB   页数:11页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

python正则表达式re模块.docx

上传人:2112770869 2019/2/22 文件大小:30 KB

下载得到文件列表

python正则表达式re模块.docx

文档介绍

文档介绍:Python正则基本说明之前讲过关于Python正则的,都是理论的东西,现在讲讲Python正则re模块。导入re模块:importre 查看帮助文档: 下面就是输出的帮助文档:Supportforregularexpressions(RE).-bitandUnicodestrings;,like"A","a",or"0",arethesimplestregularexpressions;,solastmatchesthestring'last'.Thespecialcharactersare:"."Matchesanycharacterexceptanewline."^"Matchesthestartofthestring."$"Matchestheendofthestringorjustbeforethenewlineattheendofthestring."*"Matches0ormore(greedy)."+"Matches1ormore(greedy)repetitionsoftheprecedingRE."?"Matches0or1(greedy)oftheprecedingRE.*?,+?,??Non-greedyversionsofthepreviousthreespecialcharacters.{m,n}MatchesfrommtonrepetitionsoftheprecedingRE.{m,n}?Non-greedyversionoftheabove."\\"Eitherescapesspecialcharactersorsignalsaspecialsequence.//FROMTHISWEBSITE:[]"^"plementingset."|"A|B,createsanREthatwillmatcheitherAorB.(...).(?iLmsux)SettheI,L,M,S,U,orXflagfortheRE(seebelow).(?:...)Non-groupingversionofregularparentheses.(?P<name>...)essiblebyname.(?P=name)Matchesthetextmatchedearlierbythegroupnamedname.(?#...)Acomment;ignored.(?=...)Matchesif...matchesnext,butdoesn'tconsumethestring.(?!...)Matchesif...doesn'tmatchnext.(?<=...)Matchesifprecededby...(mustbefixedlength).(?<!...)Matchesifnotprecededby...(mustbefixedlength).(?(id/name)yes|no)Matchesyespatternifthegroupwithid/namematched,the(optional)"\\",thentheresultingREwillmatchthesecondcharacter.\numberMatchesthecontents