vm bug?

P

Peter

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 ([email protected])
 
R

Ryan Stewart

Peter said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

comp.lang.java.gui FAQ 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top