What's wrong with Matcher.matches()
Look at the following code:
String regex = "(\\x2A*\\p{Space}*)*";
Pattern strangePatter = Pattern.compile(regex);
Matcher m = strangePatter.matcher("***********************************" +
"******************************************** * ");
if (m.matches())
System.out.println("Matched");
else
System.out.println("No.");
This code stucks at "if (m.matches())" and m.matches() never returns. What could be the problem?
[487 byte] By [
dr_wack] at [2007-9-30 12:18:49]

I get this problem too. Windows JVM 1.4.2_05 and prior.
In my case I have a 32000 char string with the words "toes toes toes"... and so on (don't ask why).
I am trying to locate any email addresses in this text using:
static Pattern bodyAddrPattern = Pattern . compile ("(\\w[-a-zA-Z0-9' ]*[^ ]) *\\[(?:SMTP|mailto):([^]]+)\\]");
This does not return. It does not consume any additional memory. It just uses 99% of cpu, for hours on end!
This pattern is used successfully on thousands of other strings. And if I truncate the string to 2000 characters, then it works.
> I get this problem too. Windows JVM 1.4.2_05 and
> prior.
>
> In my case I have a 32000 char string with the words
> "toes toes toes"... and so on (don't ask why).
>
> I am trying to locate any email addresses in this text
> using:
>
> static Pattern bodyAddrPattern = Pattern . compile
> ("(\\w[-a-zA-Z0-9' ]*[^ ])
> *\\[(?:SMTP|mailto):([^]]+)\\]");
>
>
> This does not return. It does not consume any
> additional memory. It just uses 99% of cpu, for hours
> on end!
>
> This pattern is used successfully on thousands of
> other strings. And if I truncate the string to 2000
> characters, then it works.
I suspect that you do a test timing for strings in a range like (10, 20,...100, 200,...900, 1000, 2000,....9000,... ) you will see that the time for each increases exponentially.