看不清
√十天内免登录忘记密码?
还没账号?马上注册
等价于
上面的函数返回都可以在if条件语句中进行判断:
(留的是中间的,因为中间在中心)
上面的函数中,只有match、search有group方法,其他的函数没有。
全部评分
总计:赞0次
Abby
谢谢楼主分享
K哥馆
最后发贴: 2024-10-21 23:09
一个高大上的名字
最后发贴: 2016-03-18 20:26
课课家运营团队
最后发贴: 2021-11-01 22:54
起个名字你猜我叫啥
最后发贴: 2016-03-08 22:23
一路风景都看透
最后发贴: 2016-03-08 22:18
论坛站务软件水平考试华为认证计算机等级PMP认证思科认证Photoshop3DMAX编程语言移动开发系统运维产品运营淘宝营销办公软件Ps修图云计算大数据摄影就业
<h1 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 26px; font-stretch: normal; line-height: 40px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">re模块下的函数</h1><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">compile(pattern):创建模式对象</h2><p><img src="/Public/forum/ueditor/image/20171024/1508807885840137.png" title="1508807885840137.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">search(pattern,string):在字符串中寻找模式</h2><p><img src="/Public/forum/ueditor/image/20171024/1508807905602144.png" title="1508807905602144.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">match(pattern,string):在字符串开始处匹配模式</h2><p><img src="/Public/forum/ueditor/image/20171024/1508807919482790.png" title="1508807919482790.png" alt="image.png"/></p><p><span style="color: rgb(46, 46, 46); font-family: "Microsoft YaHei", 宋体, "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">等价于</span></p><p><img src="/Public/forum/ueditor/image/20171024/1508807932183351.png" title="1508807932183351.png" alt="image.png"/></p><p><span style="color: rgb(46, 46, 46); font-family: "Microsoft YaHei", 宋体, "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgb(255, 255, 255);">上面的函数返回都可以在if条件语句中进行判断:</span></p><p><img src="/Public/forum/ueditor/image/20171024/1508807946868443.png" title="1508807946868443.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">split(pattern,string):根据模式分割字符串,返回列表</h2><p><img src="/Public/forum/ueditor/image/20171024/1508807964215830.png" title="1508807964215830.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">findall(pattern,string):列表形式返回匹配项</h2><p><img src="/Public/forum/ueditor/image/20171024/1508807979782011.png" title="1508807979782011.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">sub(pat,repl,string) :用repl替换 pat匹配项</h2><p style="border: 0px; margin-top: 0px; margin-bottom: 20px; padding: 0px; font-size: 15px; color: rgb(46, 46, 46); font-family: "Microsoft YaHei", 宋体, "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);"><em style="border: 0px; margin: 0px; padding: 0px;">(留的是中间的,因为中间在中心)</em></p><p><img src="/Public/forum/ueditor/image/20171024/1508808082725509.png" title="1508808082725509.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">escape(string) :对字符串里面的特殊字符串进行转义</h2><p><img src="/Public/forum/ueditor/image/20171024/1508808118898271.png" title="1508808118898271.png" alt="image.png"/></p><p style="border: 0px; margin-top: 0px; margin-bottom: 20px; padding: 0px; font-size: 15px; color: rgb(46, 46, 46); font-family: "Microsoft YaHei", 宋体, "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">上面的函数中,只有match、search有group方法,其他的函数没有。</p><p style="border: 0px; margin-top: 0px; margin-bottom: 20px; padding: 0px; font-size: 15px; color: rgb(46, 46, 46); font-family: "Microsoft YaHei", 宋体, "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-family: sans-serif; font-size: 16px;"><br/></span></p><p style="border: 0px; margin-top: 0px; margin-bottom: 20px; padding: 0px; font-size: 15px; color: rgb(46, 46, 46); font-family: "Microsoft YaHei", 宋体, "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-family: sans-serif; font-size: 16px;"></span></p><h1 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 26px; font-stretch: normal; line-height: 40px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">函数的方法</h1><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">group:获取子模式(组)的匹配项</h2><p><img src="/Public/forum/ueditor/image/20171024/1508808172676416.png" title="1508808172676416.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">start:给定组匹配项的开始位置</h2><p><img src="/Public/forum/ueditor/image/20171024/1508808185175331.png" title="1508808185175331.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">end:给定组匹配项的结束位置</h2><p><img src="/Public/forum/ueditor/image/20171024/1508808196934367.png" title="1508808196934367.png" alt="image.png"/></p><p><br/></p><h2 style="border: 0px; margin: 0px 0px 20px; padding: 0px; font-size: 24px; font-stretch: normal; line-height: 36px; font-family: "Microsoft YaHei", "Myriad Pro", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(46, 46, 46); white-space: normal; background-color: rgb(255, 255, 255);">span: 给定组匹配项的开始结束位置</h2><p><img src="/Public/forum/ueditor/image/20171024/1508808211410289.png" title="1508808211410289.png" alt="image.png"/></p>