Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

has String.replaceAll() changed from JDK 1.5.X to 1.6? (back slashes gone)

807603Nov 25 2007 — edited Nov 26 2007
public class StringReplace {
	public static void main(String[] args) {
String in = "thisLocation + escape(\"####\") ";
String out = in.replaceAll("####", "C:\\Documents and Settings\\ap\\My Documents\\w r_file");
System.out.println(out);
	}
}
Here is the output when you run under (for me): Java 1.6.0_03

thisLocation + escape("C:Documents and SettingsapMy Documentsw r_file")


Why are the backslashes swallowed up? Under java.util.regex.Pattern javadocs, '\\' is listed as backslash.

This used to work in Java 1.5.11.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 24 2007
Added on Nov 25 2007
5 comments
507 views