我需要为我的the double backslash (\\)
准备一个查询以查找某些特定数据,但我遇到SQL
的问题,因为我可以逃避所有其余但不是这个,{{ 1}}需要四个反斜杠才能正常工作Java
因为我们知道每两个反斜杠改为一个,所以我不能在行中得到四个。
任何想法都会非常有用。
这是我的方法:
public static String escapeMetaCharacters(String inputString){
final String[] metaCharacters = {"\\","^","$","{","}","[","]","(",")",".","*","+","?","|","<",">","-","&"};
String outputString="";
for (int i = 0 ; i < metaCharacters.length ; i++){
if(inputString.contains(metaCharacters[i])){
outputString = inputString.replace(metaCharacters[i],"\\"+metaCharacters[i]);
inputString = outputString;
}
}
return outputString;
}