Hello i need a regex for name validation in java. Both first and last names are in one string. both names need to be capitalized and allow hyphenated names.
valid: John Smith, John-Doe Smith, John Smith-Doe
invalid: john smith, John-doe Smith, John Smith-doe
so far i have tried this:
[A-Z][a-z]{0,20}\s[A-Z][-a-zA-Z]{0,40}
but can't get it to catch if the name after the dash starts with lowercase