最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【教程】详解Python正则表达式之: ‘$’ dollar 美元符号 匹配字符串末尾

Python re crifan 3388浏览 0评论

Python 2.7手册中的官方解释为:

'$'

Matches the end of the string or just before the newline at the end of the string, and in MULTILINE mode also matches before a newline. foo matches both ‘foo’ and ‘foobar’, while the regular expression foo$ matches only ‘foo’. More interestingly, searching for foo.$ in 'foo1\nfoo2\n' matches ‘foo2’ normally, but ‘foo1’ in MULTILINE mode; searching for a single $ in 'foo\n' will find two (empty) matches: one just before the newline, and one at the end of the string.

下面就来详细解释一下具体含义:

1.

转载请注明:在路上 » 【教程】详解Python正则表达式之: ‘$’ dollar 美元符号 匹配字符串末尾

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
61 queries in 0.113 seconds, using 18.83MB memory