Java examples for java.util.regex:Match Email
Determine if the given address is a valid email short code using regex
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String address = "java2s.com"; System.out.println(isShortCode(address)); }//from w w w. j av a 2 s . c om private final static String REG_EX_SHORT_CODE = "\\d{3,8}"; /** * Determine if the given address is a valid email short code * @param address the address to validate * @return {Boolean} whether or not address is a valid short code * @method isShortCode * @static */ public static boolean isShortCode(String address) { return address != null && address.matches(REG_EX_SHORT_CODE); } }