gpt4 book ai didi

python - 这个正则表达式是否意味着它必须以 A 开头,以 Z 结尾?研究 "\A[0-9A-Za-z_-]+\Z"

转载 作者:太空狗 更新时间:2023-10-30 02:14:10 27 4
gpt4 key购买 nike

这个正则表达式是否意味着它必须以 A 开头,以 Z 结尾?

re.search("\A[0-9A-Za-z_-]+\Z", sometext)

最佳答案

不,那些是anchors .

\A表示字符串开始,\Z表示字符串结束。同样,^ 表示行首,$ 表示行尾。

参见 documentation for the re module .

\A - Matches only at the start of the string.
\Z - Matches only at the end of the string.

关于python - 这个正则表达式是否意味着它必须以 A 开头,以 Z 结尾?研究 "\A[0-9A-Za-z_-]+\Z",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3524788/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com