I think it returns true only if the entire string matches the regular
expression. Therefore your first example:
matches("Hello", "e*")
would match any number of "e's" (including an empty string).
If you want to know if there is any "e" in the string at all, try:
matches("Hello",".*e.*);
Based on your examples, it looks like you know about regular
expressions already, but I find this website useful:
http://www.regular-expressions.info/ . If you want some dense reading
you can do 'man 7 regex' on Linux or related systems.
Justin
On Mon, Jan 12, 2009 at 10:53 AM, Mat Hickman <
[hidden email]> wrote:
> Hi,
>
> It's possible that I'm being useless when it comes to regular expressions,
> but I'm really struggling to get the matches function to work. I test my
> regex on websites and it suggests that they work fine, but 'matches'
> stubbornly keeps returning zero. I've resorted to a brute-force approach,
> just trying lots and lots of different regex's, but all to no avail. Is
> there any chance someone could post a few examples?
>
> Thus far I've tried:
> matches("Hello", "e*")
> matches("Hello", "e")
> matches("Hello", "/e/")
> matches("Hello", "(e)")
> matches("Hello", "m/e/")
> matches("Hello", "/[e]/")
> etc etc.
>
> All combinations therein as well.
>
> Any help would be greatly appreciated.
>
> Best wishes,
>
> Mat
>