0

Regular expression (Regex) for validating ip address?

4th Mar 2020, 4:20 PM
AMISHA NARSINGANI
AMISHA NARSINGANI - avatar
2 Respostas
+ 3
for ipv4 easiest regex would be [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} but major flaw on this, is 999.999.999 is still correct ¯\_(ツ)_/¯ maybe regex isnt the best way
4th Mar 2020, 4:23 PM
Taste
Taste - avatar
+ 2
Fully correct for IPv4: ((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])
5th Mar 2020, 3:49 PM
Vlad Serbu
Vlad Serbu - avatar