StringUtils isNumeric returns true when input is “

2019-04-09 13:53发布

This question already has an answer here:

I was reading the commons.apache.org isNumeric method definition and it states:

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

I am not sure why "???" is considered to be numeric. My guesses are:

  • A "?" is considered a unicode digit
  • It is some kind of regex pattern

isNumeric Method Definition

2条回答
smile是对你的礼貌
2楼-- · 2019-04-09 14:25

I was able to find the answer to this question by looking at the StringUtils source code for the isNumeric method. In the source code that line appears as:

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

Where u0967, u0968, u0969 are Devangari Digits one, two, and three respectively. This may be a browser issue causing the characters to not be rendered correctly in the API.

查看更多
唯我独甜
3楼-- · 2019-04-09 14:27

Looking at the code, the example is

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

\u0967 is , which is "Devanagari Digit One"

\u0967 is , which is "Devanagari Digit Two"

So they are digits!

查看更多
登录 后发表回答