Here you can find the source of isIPAndPort(String text)
public static boolean isIPAndPort(String text)
//package com.java2s; //License from project: LGPL import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isIPAndPort(String text) { if (isEmpty(text)) return false; String[] texts = text.split(":"); if (texts.length != 2) return false; Pattern pattern = Pattern.compile( "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))$"); Matcher matcher = pattern.matcher(texts[0]); if (matcher.find()) { return texts[1].matches("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-5][0-5][0-3][0-5])$"); }// w w w . ja va 2s . com return false; } public static boolean isEmpty(String text) { return (text == null || text.trim().isEmpty()); } }