Back to project page Android-sample.
The source code is released under:
Apache License
If you think the Android project Android-sample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.andreabaccega.formedittextvalidator; /* w w w .j av a 2 s . c o m*/ import java.util.regex.Pattern; import android.os.Build; import android.util.Patterns; /** * Validates the ipaddress. The regexp was taken from the android source code. * @author Andrea Baccega <me@andreabaccega.com> * */ public class IpAddressValidator extends PatternValidator{ public IpAddressValidator(String _customErrorMessage) { super(_customErrorMessage, Build.VERSION.SDK_INT>=8?Patterns.IP_ADDRESS:Pattern.compile( "((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]" + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]" + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}" + "|[1-9][0-9]|[0-9]))")); } }