Regular expression (Regex) for validating ip address? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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