当输入为“???”时,StringUtils isNumeric 返回 true,为什么? [复制]

2024-02-20

我正在阅读 commons.apache.orgisNumeric http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#isNumeric%28java.lang.CharSequence%29方法定义及其说明:

StringUtils.isNumeric("???") = true;

我不知道为什么"???"被认为是数字。我的猜测是:

  • A "?"被视为 unicode 数字
  • 这是某种正则表达式模式

我通过查看这个问题找到了答案字符串实用程序 https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.htmlisNumeric 方法的源代码。 在源代码中,该行显示为:

StringUtils.isNumeric("\u0967\u0968\u0969")  = true

其中 u0967、u0968、u0969 是德万加里数字 https://en.wikipedia.org/wiki/Devanagari#Unicode分别为一、二、三。 这可能是浏览器问题导致 API 中的字符无法正确呈现。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当输入为“???”时,StringUtils isNumeric 返回 true,为什么? [复制] 的相关文章

随机推荐