about | help | code help+videos | done | prefs |
welcomeback_regex_phoneOrName
Given a String, return "phone" if it is a phone number, "name" if it is a name, and "neither" if it is neither. Phone numbers must be 3 digits, a dash, 3 digits, a dash, and then 4 digits. A name must be a capital letter followed by 1 or more lowercase letters. The names will only be last names with no spaces. Note: You cannot import java.util.regex, instead use the String class method "matches" as shown below. String phonePattern = "YOUR CODE GOES HERE"; if(input.matches(phonePattern)) { return "phone"; } welcomeback_regex_phoneOrName("123-456-7890") → "phone" welcomeback_regex_phoneOrName("123-456-78900") → "neither" welcomeback_regex_phoneOrName("Monroe") → "name" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy