Java tutorial
//package com.java2s; public class Main { public static boolean isNumOrWord(String str) { String regularExpression = "[a-z0-9A-Z]*"; if (isEmpty(str)) { return false; } else if (!str.matches(regularExpression)) { return false; } return true; } public static boolean isEmpty(String str) { if (str != null && !"".equals(str.trim())) { return false; } return true; } }