[英]Validate MAC and IP addresses in Java
I am writing a program to read in data from an excel sheet which contains a bunch of info about computers which will be entered by the user. 我正在编写一个程序来读取excel表中的数据,该表包含一堆有关计算机的信息,这些信息将由用户输入。 This excel file will then be converted to a different format for other uses.
然后,此excel文件将转换为其他用途的其他格式。 I can read all the values no problem but I just need help validating MAC and IP addresses entered by the user to make sure the information is correct.
我可以读取所有值没问题,但我只需要帮助验证用户输入的MAC和IP地址,以确保信息正确。 Some regular expressions for this would be great as I am sure I would use them again at some stage.
一些正则表达式会很好,因为我相信我会在某个阶段再次使用它们。
Thanks. 谢谢。
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"
([0-9A-F]{2}[:-]){5}([0-9A-F]{2}) ([0-9A-F] {2} [: - ]){5}([0-9A-F] {2})
This is for mac address 这是用于mac地址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.