java - Use Regex to accept a string as long as it contains alphabet -


i want accept string long contains alphabetical letters, example: string teststr = "hello world 1. ?"

i using this: teststr.matches("^[a-za-z\\s]+"), won't accept strings have characters outside of alphabet.

so wondering how use regex in situation.

could use lookahead check if string contains @ least 1 [a-z]

(?i)^(?=.*[a-z]).* 

or without i-caseless modifier: ^(?=.*[a-za-z]).* / check only: ^(?=.*[a-za-z])

test @ regex101


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -