Rails 3: Validate IP String

后端 未结 7 875
孤独总比滥情好
孤独总比滥情好 2020-12-13 18:41

In Rails 3, is there a built in method for seeing if a string is a valid IP address?

If not, what is the easiest way to validate?

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 19:09

    You can also use Regexy::Web::IPv4 which can match ip addresses with port numbers too.

提交回复
热议问题