RegEx for an IP Address

前端 未结 12 1581
不知归路
不知归路 2020-11-29 03:52

I try to extract the value (IP Address) of the wan_ip with this sourcecode: Whats wrong?! I´m sure that the RegEx pattern is correct.

String input = @\"var p         


        
12条回答
  •  伪装坚强ぢ
    2020-11-29 04:21

    Very old post, you should use the accepted solution, but consider using the right RegEx for an IPV4 adress :

    ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
    

    If you want to avoid special caracters after or before you can use :

    ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
    

提交回复
热议问题