我是全新到Android。
I'm totally new to Android.
我想提出的一个文本框,其中用户可以输入一个IP地址,...但我怎么限制为仅输入数字的用户? ......,我如何验证?
I would like to put in a textbox where user can enter an IP address ... but how do I limit the user to only enter numbers? ... and how do I validate?
有没有现成的-IP地址的文本框那里我可以使用?
Is there a ready-made-ip-address-textbox "out there" I can use?
谢谢!
魔
推荐答案
有关验证,定期-EX pressions.info 有,你可以在一个有效的(0-255)范围内用于测试一个IP一个良好的正则表达式字符串:
For validation, regular-expressions.info has a good regex string you could use for testing for an IP in a valid (0-255) range:
b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b
b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b
相关推荐
最新文章