Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  45] [ 1]  / answers: 1 / hits: 10490  / 10 Years ago, thu, march 6, 2014, 12:00:00

I am using URL Matching with parent domain and I-Frame domain. Getting this error to put the below code inside Java Class.



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


Getting Error for this line:



Invalid escape sequence (valid ones are b t n f r  ' \ )


Original script:



    out.print(<script>);


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



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


How to use this correctly?


More From » java

 Answers
2

In a Java string, to actually have a backslash you have to escape it with another backslash. So all should be escaped with another in your out.print line:



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


That outputs this:



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

[#47129] Wednesday, March 5, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lesterluiss

Total Points: 513
Total Questions: 104
Total Answers: 106

Location: Honduras
Member since Sat, Jul 24, 2021
3 Years ago
;