Source Code : Match Name
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Match Name

public class MatchNameFormats {
public static void main(String args[]) {
isNameValid("John Smith");
isNameValid("John McGee");
isNameValid("John Willliam Smith");
isNameValid("John Q Smith");
isNameValid("John allen Smith");
isNameValid("John");
}
public static boolean isNameValid(String name) {
boolean retval = false;
String nameToken = "\p{Upper}(\p{Lower}+\s?)";
String namePattern = "(" + nameToken + "){2,3}";
retval = name.matches(namePattern);
String msg = "NO MATCH: pattern:" + name + "
regex :"
+ namePattern;
if (retval) {
msg = "MATCH pattern:" + name + "
regex :"
+ namePattern;
}
System.out.println(msg + "
");
return retval;
}
}
Thank with us