Simple Regex Not Working
Hi,
Can somebody tell me why the following regex matching does not work:
Pattern.matches("(hi)*","hithere");
Hi,
Can somebody tell me why the following regex matching does not work:
Pattern.matches("(hi)*","hithere");
> Hi,
>
> Can somebody tell me why the following regex matching
> does not work:
>
> > Pattern.matches("(hi)*", "hithere");
>
Your regex would only match
"hi" or "hihi" or "hihihi" etc.
I suspect you need as regex "hi.*" .
Argh! Thank you for pointing that out. Actually this should work: .*(hi).* as I am interested in finding that particular string anywhere in the input.