1) The replace parameter is Char and charsequence, which can be used to replace characters or strings (charsequence is the meaning of string sequence, which is a string in White );
2) The replaceall parameter is RegEx, that is, the replacement based on the Rule expression. For example, you can use replaceall ("\ D ","*") replace all numeric characters in a string with asterisks;
Example:
String src = new string ("ab43a2c43d ");
System. Out. println (SRC. Replace ("3", "F "));
System. Out. println (SRC. Replace ('3', 'F '));
System. Out. println (SRC. replaceall ("\ D", "F "));
System. Out. println (SRC. replaceall ("A", "F "));
System. Out. println (SRC. replacefirst ("\ D", "F "));
System. Out. println (SRC. replacefirst ("4", "H "));
How to replace "\" in a string "\\":
String msgin;
String msgout;
Msgout = msgin. replaceall ("\\\\","\\\\\\\\");
Cause:
'\' Is an escape character in Java, so two must be used to represent one. For example, system. Out. println ("\"); only one "\" is printed "\". However, '\' is also the Escape Character in the regular expression (The replaceall parameter is the regular expression), and two must be used to represent one. Therefore, \\\\ is converted to \\\, \\by a regular expression \.
Similarly
Code :\\\\\\\\
Java :\\\\
RegEx :\\
Several Methods to replace '/' with '\' in a string:
Msgout = msgin. replaceall ("/","\\\\");
Msgout = msgin. Replace ("/","\\");
Msgout = msgin. Replace ('/','\\');
This is some information on the Internet, first recorded, and then more important !! Resolving ............ To be continued !!