javascript - Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ ) in java -


i using url matching parent domain , i-frame domain. getting error put below code inside java class.

out.print("ref = url.match(/:\/\/(.[^/]+)/)[1];"); 

getting error line:

invalid escape sequence (valid ones \b \t \n \f \r \" \' \\ ) 

original script:

    out.print("<script>"); 

//need put below line inside java class, using out.print(" ");

ref = url.match(/:\/\/(.[^/]+)/)[1]; out.print("</script>"); 

how use correctly?

in java string, have backslash have escape backslash. \ should escaped \ in out.print line:

out.print("ref = url.match(/:\\/\\/(.[^/]+)/)[1];");                       //     ^  ^ 

that outputs this:

ref = url.match(/:\/\/(.[^/]+)/)[1]; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -