i have regex ** **
i using preg_match_all method in php match ips. doesn't match ip if last octet 3 digits. plz can me , let me know going wrong.
code like:
$tnlip_regex = "/(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])[\.])(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])[\.])(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])[\.])(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5]))/"; preg_match_all($tnlip_regex, $row_data, $tnlip_matches); $row_data data finding ips. $tnlip_matches array putting them.
your regexp looks wrong follows-

you need this-
^([0-9]|[1-9][0-9]|(1[0-9]{2}|2[0-5]{2}))\.([0-9]|[1-9][0-9]|(1[0-9]{2}|2[0-5]{2}))\.([0-9]|[1-9][0-9]|(1[0-9]{2}|2[0-5]{2}))$ 
you can test validity of ip address using rule here : debuggex demo
Comments
Post a Comment