Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { final static private String rut_pattern = "^(\\d{2}\\.\\d{3}\\.\\d{3}-)([a-zA-Z]{1}$|\\d{1}$)\n"; static public Boolean rutValidation(String rut) { Pattern p = Pattern.compile(rut_pattern); Matcher m = p.matcher(rut); while (m.find()) { return true; } return false; } }