Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isNameValid(String name) { final String NAME_PATTERN = "[A-Z][a-z]+( [A-Z][a-z]+)?"; Pattern pattern = Pattern.compile(NAME_PATTERN); Matcher matcher = pattern.matcher(name); return matcher.matches(); } }