KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I validate regex for full name? I only want alphabets (no numericals) and only spaces for the regex. This is what I have done so far. Would you please help me fix the regex? Thank you very much public static boolean isFullname(String str) { boolean isValid = false; String expression = "^[a-zA-Z][ ]*$"; //I know this one is wrong for sure >,< CharSequence inputStr = str; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true; } return isValid; }
Tags (comma-separated)
Save Edits
Cancel