import java.util.regex.Matcher;import java.util.regex.Pattern;/** * JavaString * com.xuyanghui.regularexPRession * 15-10-24 * 下午2:31 * YANGHUI XU */public class Regular { public static void main(String[] args) { String ip = "192.168.1.108"; String patternString = "(([0,1]?//d?//d|2[0-4]//d|25[0-5])//.){3}([0,1]?//d?//d|2[0-4]//d|25[0-5])"; Pattern pattern = Pattern.compile(patternString); Matcher matcher = pattern.matcher(ip); System.out.println(matcher.matches()); }}
新闻热点
疑难解答