简体   繁体   English

正则表达式:美元符号($)与re.match()或re.search()一起使用?

[英]regular expression : the dollar sign ($) work with re.match() or re.search() ?

我只知道美元符号$将匹配字符串末尾的模式,但是re.match()re.search()可以使用哪种方法?

It works with both the .search() and .match() methods. 它的工作原理与两个.search().match()方法。

.match() is anchored to the start of the string, but you can still require that the whole string matches by including a $ anchor. .match()锚定在字符串的开头,但是您仍然可以通过包含$锚来要求整个字符串匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM