URL正则
((http|ftp|https|udp)://)(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?
示例:
public class Demo {
public static void main(String[] args) throws IOException {
String ip = "udp://225.100.100.100:6666";
boolean b = ip.matches("((http|ftp|https|udp)://)(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?");
System.out.println(b);
}
}
日期
String content = "2020-2-31";
boolean isMatch = ReUtil.isMatch("\\d{4}\\-(0?[1-9]|[1][012])\\-(0?[1-9]|[12][0-9]|3[01])", content);
时分秒
String content = "11:00:00";
boolean isMatch = ReUtil.isMatch("([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])", content);