gpt4 book ai didi

Python 正则表达式 '\s' 与 unicode BOM (U+FEFF) 不匹配

转载 作者:太空狗 更新时间:2023-10-29 20:15:25 25 4
gpt4 key购买 nike

Python re 模块的 documentation表示当设置了 re.UNICODE 标志时,'\s' 将匹配:

whatever is classified as space in the Unicode character properties database.

据我所知, Material list (U+FEFF) 是 classified as a space .

但是:

re.match(u'\s', u'\ufeff', re.UNICODE)

评估为

这是 Python 中的错误还是我遗漏了什么?

最佳答案

根据 unicode 数据库,U+FEFF 不是空白字符。

维基百科仅将其列为“相关字符”。这些类似于空白字符,但在数据库中没有 WSpace 属性。

\s 不匹配这些字符。

关于Python 正则表达式 '\s' 与 unicode BOM (U+FEFF) 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32506708/

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