The former is a replacement of a common string of characters and symbols, and the latter is a replacement of regular expressions.
Eg:
String STR = "2008.1.12 ";
You need to replace "." In the string "_".
One way is to honestly use Str. Replace (".","_");
If Str. replaceall (".", "_") is used (".","_")
All characters in STR will be replaced "_".
Because in a regular expression, "." represents any character.
The correct method is to use escape characters in the first parameter of replaceall to construct a correct regular expression.
For example:
Str. replaceall ("//.","_");
Replaceall example:
Public static string datetofilename (string date ){
String separator = "_";
Date = date. replaceall ("", separator );
Date = date. replaceall ("//.", separator );
Date = date. replaceall (":", separator );
Date = date. replaceall ("-", separator );
Date = date. replaceall ("/", separator );
Return date;
}