Java tutorial
//package com.java2s; public class Main { private static final String RCID_REGEX = "(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{2,})$"; public static final int RCID_MIN_LENGTH = 4; public static final int RCID_MAX_LENGTH = 20; public static boolean isRCIDMatches(String rcId) { rcId = rcId.trim(); int textLength = rcId.length(); return rcId.matches(RCID_REGEX) && textLength >= RCID_MIN_LENGTH && textLength <= RCID_MAX_LENGTH; } }