All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.archive.util.StringParse Maven / Gradle / Ivy

There is a newer version: 1.1.9
Show newest version
package org.archive.util;

import java.util.List;
import java.util.regex.Pattern;

public class StringParse {
	private final static Pattern IP_PATTERN =
        Pattern.compile("b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).)"
                              + "{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b");
	public static boolean isIP(final String ip) {
		// TODO:
		return ip.length() > 0;
//		return IP_PATTERN.matcher(ip).matches();
	}
	public static boolean isIPBad(final String ip) {
		return IP_PATTERN.matcher(ip).matches();
	}
	public static String join(List p) {
		return join(p,",");
	}
	public static String join(List p, String delim) {
		StringBuilder sb = new StringBuilder();
		boolean first = true;
		for(String part : p) {
			if(first) {
				first = false;
			} else {
				sb.append(delim);
			}
			sb.append(part);
		}
		return sb.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy