I am trying to replace the backslash (escape) character in a Javascript string literal.
I need to replace it with a double backslash so that I can then do a redirec
<< Escape Characters Replacement>>
import java.util.Scanner;
public class Example7 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Please enter a sentence: ");
String a=in.nextLine();
//System.out.println("the word had enter: "+a);
String Str1 = a.replace("\\n", "(new_line)");
//System.out.println(Str1);
String Str2 = Str1.replace("\\t", "(tab)");
//System.out.println(Str2);
String Str3 = Str2.replace("\\t", "(tab)");
String Str4 = Str3.replace("\\\\", "(comment_line)");
String Str5 = Str4.replace(":)", "(smile) ");
System.out.println("The new sentence:" +Str5);
}
}