Skip to content

Instantly share code, notes, and snippets.

@zebulon988
Created November 26, 2016 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zebulon988/0d288feae956b6c1322cb5b401cc0bbd to your computer and use it in GitHub Desktop.
Save zebulon988/0d288feae956b6c1322cb5b401cc0bbd to your computer and use it in GitHub Desktop.
java code call js method which has string params ,you should wrap the string
public static String wrapStringForJsCallParams(String str){
if(TextUtils.isEmpty(str)) return str;
str = str.replaceAll("\\\\" , "\\\\\\\\");
str = str.replaceAll("'" , "\\\\'");
str = str.replaceAll("\"" , "\\\\\"");
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment