I need to check correctness of input string using regex pattern, every word should start with capital letter, also at the end there could be expression separated with "-". String should contain at least two words or expression with dash.
e.g.
correct:
Apple Banana Couonut-Dates
Apple Banana
Banana Couonut-Dates
Couonut-Dates
incorrect:
Apple
Apple Banana Couonut-dates
BanAna couonut-Dates
Pattern pattern = Pattern.compile("([A-Z][a-z]++ )*([A-Z][a-z]++-[A-Z][a-z]++)");
pattern.matcher("Apple Banana Couonut-Dates").matches();
For input "Apple Banana Couonut-Dates" my expression returns false