gpt4 book ai didi

.net -\d 与 .NET 正则表达式中的 [0-9]

转载 作者:行者123 更新时间:2023-12-04 23:03:46 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





\d less efficient than [0-9]

(5 个回答)


8年前关闭。




经常看到[0-9]在 Stack Overflow 上的 .NET 正则表达式答案中使用,而不是 \d .我问过为什么,答案往往是“\d匹配的不仅仅是 [0-9] ”。那么它还有什么匹配呢? This table说它匹配十进制数字。那么\p{Nd} ?

或者没有区别,这只是因为其他一些正则表达式引擎的好习惯?

最佳答案

我想答案也在linked reference :

\d matches any decimal digit. It is equivalent to the \p{Nd} regular expression pattern, which includes the standard decimal digits 0-9 as well as the decimal digits of a number of other character sets.



所以 \d可以匹配阿拉伯字符集中的十进制数字之类的东西,这些东西不会与 [0-9] 匹配。 .

关于.net -\d 与 .NET 正则表达式中的 [0-9],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17194645/

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