最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

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

Python re crifan 8677浏览 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,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.176 seconds, using 22.06MB memory