1.Java String类的replaceAll()
1.1 java 把反斜杠(\)替换成双斜杠(\)
replaceAll( “\\”, “\\\\”);
1.2 java 把反斜杠(\)替换成斜杠(/)
replaceAll( “\\”, “/”);
1.3 java 把斜杠(/)替换成反斜杠(\)
replaceAll(“\/”,“\\”);
2. Java拼接和split
2.1拼接
最终想要如下结果:
database\schema\table\column
String a = “database”
String b = “schema”
String c = “table”
String d = “column”
String result = a + “\” + b + “\” + c + “\” + d
2.2 split
最终想要将下面的字符串切割:
database\schema\table\column
//path通过参数传过来
String[] pathSplit = path.split(“\\”);
List pathList = Arrays.asList(pathSplit)
3. JavaScript的replace
3.1 javascript 把反斜杠(\)替换成双斜杠(\)
replace(/\/g,“\\”);
3.2 javascript 把反斜杠(\)替换成斜杠(/)
replace(/\/g,“/”);
3.3 javascript 把斜杠(/)替换成反斜杠(\)
replace(///g,“\”);
来源地址:https://blog.csdn.net/qq_40112624/article/details/129876259