Java tutorial
//package com.java2s; public class Main { private static final String regExp = "[^a-zA-Z0-9.-]"; public static boolean isValidRouteName(String routeName) { return !isNullOrEmpty(routeName) && routeName.replaceAll(regExp, "_").equals(routeName); } public static boolean isNullOrEmpty(String s) { return s == null || s.length() == 0; } }