There's two things:

1. \D refers to everything that is NOT a number digit! \d is what you
need;
2. In Java, you must write the String \d, so, as the backslash in a
String is wrote as two backslashes ("\\"), your pattern must match THE
STRING \\d, which means the pattern \d

so your code will look like
string.matches("\\d");

:)

On Apr 2, 11:39 am, Lovedumplingx <[email protected]> wrote:
> Ok...so I need to do some pattern matching.
>
> I'm no regular expressions genius but it shouldn't be too hard right?
>
> so I'm using:
>
> string.matches("");
>
> in order to evaluate the string.  My problem is that Eclipse doesn't
> seem to like any of my regular expressions I'm putting in there.
>
> According to the information found here:http://developer.android.com/
> reference/java/util/regex/package-descr.html
> I should be able to use "string.matches("\D");" to describe a string
> where the first character has to be a number but Eclipse says that \D
> is an "Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \
> \ )".
>
> Any thoughts?  Have I completely messed up how matches is supposed to
> work or am I the victim of some heinous crime?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to