What does [\ 0-9] mean in regex (perl)?

[\0-9]{10,15} 

I tried to match phone numbers and ended up writing this regular expression, and it matches phones containing + , ( , ) , but I don’t understand why.

+4
source share
1 answer

\0 is the NUL byte, byte 0x0 . The range expresses a range of characters from 0x0 to "9" ( 0x39 ), which includes a bunch of characters like "+". In fact, the range covers the first 58 characters of the ASCII table. See http://www.asciitable.com .

So, "##########" will also match your regular expression.

+20
source

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


All Articles