Java examples for java.util.regex:Match IP Address
is IPv4 Literal Address by regex
/**/*from w w w. j av a 2 s. c o m*/ * Author Rigoberto Leander Salgado Reyes <rlsalgado2006@gmail.com> * <p> * Copyright 2015 by Rigoberto Leander Salgado Reyes. * <p> * This program is licensed to you under the terms of version 3 of the * GNU Affero General Public License. This program is distributed WITHOUT * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the * AGPL (http:www.gnu.org/licenses/agpl-3.0.txt) for more details. */ //package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String var0 = "java2s.com"; System.out.println(isIPv4LiteralAddress(var0)); } public static boolean isIPv4LiteralAddress(String var0) { return var0 .matches("(([1-9]|[1-9]\\d|[1]\\d\\d|[2][0-4]\\d|[2][5][0-5]|0).){3}([1-9]|[1-9]\\d|[1]\\d\\d|[2][0-4]\\d|[2][5][0-5]|0)"); } }