Posted By

arunpjohny on 03/03/11


Tagged

IPv4


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Briantjuh
macster


IPv4 RegEx


 / Published in: JavaScript
 

URL: http://en.wikipedia.org/wiki/IPv4

  1. ^(\d{1,3}\.){3}(\d{1,3})$|^(0x[\da-fA-F]{2}\.){3}(0x[\da-fA-F]{2})$|^(0[0-3][0-7]{2}\.){3}(0[0-3][0-7]{2})|^0x[\da-fA-F]{8}$|^[0-4]\d{9}$|^0[0-3]\d{10}$ //Complete definition
  2.  
  3. ^([0-2]?\d{0,2}\.){3}([0-2]?\d{0,2})$ //Simple doted address
  4. ^(0x[\da-fA-F]{2}\.){3}(0x[\da-fA-F]{2})$ //Hexa format
  5. ^(0[0-3][0-7]{2}\.){3}(0[0-3][0-7]{2}) //Octal format
  6. ^0x[\da-fA-F]{8}$ //Hexa number
  7. ^[0-4]\d{9}$ //Decimal number
  8. ^0[0-3]\d{10}$ //Octal number

Report this snippet  

You need to login to post a comment.