Both A T and Faber's solutions should work fine if you add the check
for uppercase letters also:

                String foo = "aAsdjshdIUjkshf";
                System.out.println(foo.matches("[a-zA-Z]+") ? "Yay" : "Nay" );

Prints 'yay'.

                String foo = "aAsdjs1234hdIUjkshf";
                System.out.println(foo.matches("[a-zA-Z]+") ? "Yay" : "Nay" );

Prints 'nay'.

On Jan 14, 3:20 pm, "Josh Dobbs" <joshdo...@gmail.com> wrote:
> That doesnt work either. what i want to do is check the entire length of the
> string to ensure that only a-z are in the string and that there are no
> special characters.
>
> On Wed, Jan 14, 2009 at 7:15 AM, Faber Fedor <faberfe...@gmail.com> wrote:
>
> >  On Wed, Jan 14, 2009 at 10:00 AM, Dan Dumont <ddum...@gmail.com> wrote:
>
> >> It is checking the entire length of the string...   your pattern is not
> >> doing what you want.
>
> >> I suggest you read up on regular expressions.   Your regexp says:
> >> Match 1 character a-z, followed by any character zero or more times.
>
> > No it doesn't.  It says match 1 character which is anyhing OTHER than a-z
> > followed by zero or more of any other character.
>
> > What the OP presumably wants is something like
>
> >     ^[a-z]+
>
> > which reads as "match the start of line, followed by one or more of the
> > characters 'a' through 'z'"
>
> >> On Wed, Jan 14, 2009 at 2:28 AM, Josh <joshdo...@gmail.com> wrote:
>
> >>> i have the following code in place to ensure that the user only enters
> >>> the letters a through z into the EditText control.
>
> >>> if (Pattern.matches("[^a-z].*", DrawingName.getText().toString())) {
> >>>     //do nothing for now
> >>>    DrawingName.setText("WRONG");
> >>> }
>
> >>> The problem is it only checks the first character. How can I make it
> >>> check the entire length of the string?                                  }
>
> > --
>
> > Faber Fedor
> > Cloud Computing New Jersey
> >http://cloudcomputingnj.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to