Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vm bug?

1 view
Skip to first unread message

Peter

unread,
Jan 9, 2005, 10:36:13 PM1/9/05
to
Hi
Is it a VM bug?
String str = "projects" + File.separator + "John";
System.out.println(str.replaceFirst("projects" +
File.separator,"Hello"));


Exception in thread "AWT-EventQueue-0"
java.util.regex.PatternSyntaxException: Unexpected internal error near
index 9
projects\
^
at java.util.regex.Pattern.error(Pattern.java:1650)
at java.util.regex.Pattern.compile(Pattern.java:1403)
at java.util.regex.Pattern.<init>(Pattern.java:1124)
at java.util.regex.Pattern.compile(Pattern.java:817)
at java.lang.String.replaceFirst(String.java:1967)


JDK 1.5.0-rc-b63 and 1.4.2_04-b05, same error

thanks
from Peter (cmk...@hotmail.com)

Ryan Stewart

unread,
Jan 9, 2005, 10:49:06 PM1/9/05
to
"Peter" <cmk...@hotmail.com> wrote in message
news:a52de42d.05010...@posting.google.com...

> Hi
> Is it a VM bug?
> String str = "projects" + File.separator + "John";
> System.out.println(str.replaceFirst("projects" +
> File.separator,"Hello"));
>
> Exception in thread "AWT-EventQueue-0"
> java.util.regex.PatternSyntaxException: Unexpected internal error near
> index 9
> projects\
> ^
[...]
No, it's not. The error message says it all. "projects\" is not a valid regular
expression. A "\" is an escape character. To match one, you must use "\\" (an
escaped backslash).

Next time try reading the documentation:
http://java.sun.com/j2se/1.4.2/docs/api/
http://java.sun.com/j2se/1.5.0/docs/api/

And please post basic problems to comp.lang.java.help.


0 new messages