What\'s the best and easiest way to check if a string only contains the following characters:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
if (string.matches("^[a-zA-Z0-9_]+$")) { // contains only listed chars } else { // contains other chars }