java - regex not working as expected for full name -
i have textbox taking input full name.
when user enter input my name, don't error. when user enter input my name is, error.
regex have is
([a-za-z]+|[a-za-z]+\\s[a-za-z]+) what want is, text should have
only (a-z or a-z) , white space... demo inputs are
- my name xyz pqr stu
- my name xyz
- xyz pqr stu
how can done using regex?
update 1
i using
pattern p = pattern.compile("[a-za-z\\s]"); matcher m = p.matcher("dummyname"); boolean matchfound = m.matches(); still getting matchfound false
\s whitespace. if want allow whitespace in character class upper , lowercase letters, use [a-za-z\s].
Comments
Post a Comment