\ d against [0-9] in .NET regular expressions

I often see [0-9] which is used in .NET regular expression replies in Stack instead of \d . I asked why, and the answer is usually " \d matches not only [0-9] ". So what else does this mean? This table indicates that it corresponds to decimal digits. What about \p{Nd} ?

Or is there no difference, and is it just good practice because of some other regular expression mechanism?

+4
source share
1 answer

I think the answer is also in the linked link :

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

So, \d can match elements, such as decimal digits in the Arabic character set, that will not match [0-9] .

+8
source

Source: https://habr.com/ru/post/1487067/


All Articles