Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

regex

perl

[\0-9]{10,15}  

I tried to match phone numbers and ended up writing that regex, and it does match phones containing +, (, ) , but I don't understand why.

like image 522
shrutyzet Avatar asked Nov 30 '22 03:11

shrutyzet


1 Answers

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

So "##########" would also match your regex.

like image 140
deceze Avatar answered Dec 05 '22 06:12

deceze