Java tutorial
//package com.java2s; /* * This file is part of the Droid Roach project * Copyright 2013 Stefano Gabryel * Author: Stefano Gabryel * License: GPL v3 - http://www.gnu.org/licenses/gpl-3.0.html * Author website: http://www.stefano-workshop.com * Project website: http://droid-roach.stefano-workshop.com * */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean checkIP(String value) { Pattern pattern = Pattern .compile("^([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])$"); Matcher matcher = pattern.matcher(value); boolean IPcheck = matcher.matches(); if (IPcheck) return true; return false; } }