Java Regular Expression. Check if String contains ONLY Letters

Posted by user69514 on Stack Overflow See other posts from Stack Overflow or by user69514
Published on 2010-04-24T08:40:50Z Indexed on 2010/04/24 8:43 UTC
Read the original article Hit count: 238

How do I check if a String contains only letters in java? I want to write an if statement that will return false if there is a white space, a number, a symbol or anything else other than a-z A-Z. My string must contain ONLY letters.

I thought I could do it this way, but I'm doing it wrong:

if( ereg("[a-zA-Z]+", $myString))
   return true;
else
   return false;

© Stack Overflow or respective owner

Related posts about java

Related posts about regex