Here you can find the source of isIp(String s)
Parameter | Description |
---|---|
s | a parameter |
public static boolean isIp(String s)
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /**//from w w w . j ava2 s . c o m * @param s * @return */ public static boolean isIp(String s) { String strMatch = "^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$"; Pattern ParsePattern = Pattern.compile(strMatch); Matcher ParseMatcher = ParsePattern.matcher(s); return ParseMatcher.find(); } }