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

Python Kivy ListView: How to delete selected ListItemButton? -

ruby - How do I merge two hashes into a hash of arrays? -