Question: Java For this question, consider names of cities that are made from any number of words where the first letter is always in uppercase and

Java

Java For this question, consider names of cities that are made from

For this question, consider names of cities that are made from any number of words where the first letter is always in uppercase and the words are separated by a space Implement a regular expression as a Java String p like so String p -. such that ******is a regular expression pattern that will match any String that contains the name of a city and only such strings. Your answer must include the whole line of code above, meaning that the** must be properly backslash-escaped both in terms of backslash escapes required for regular expressions and any backslash escapes required to put the expression inside the quotes above. Your answer will be inserted automatically into a test method matchO like so: public void match(String s) String p System.out.printin(s.matches(p)? "match" S: "does not match" + S) the test cases will invoke this method Example The following are valid city names . Ho Chi Minh City . Palmerston North Auckland The following are invalid city names sydney . New york For example san Francisco Test Result match("Auckland match Auckland match("sydney does not match sydney

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!