IP address regex python

前端 未结 2 1923
名媛妹妹
名媛妹妹 2021-01-21 13:22

I am having an issue with Regular expression, I need the most efficient regex that match IP address and in range of 255 only.

I tried this one \"ip_pattern = \'\

相关标签:
2条回答
  • 2021-01-21 13:43

    Use this Regex. It will match and check the IP range within 255.

    \b(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]).(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]).(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]).(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\b

    0 讨论(0)
  • 2021-01-21 13:56

    This should do it:

    ^(?:(?: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]?)$
    
    0 讨论(0)
提交回复
热议问题