http://qs321.pair.com?node_id=218793


in reply to Template-output quoting (Warning: Contains JavaScript)

But if the template code expands into "Hello Fred's World" then you'll get a syntax error as the apostrophe in Fred's is interpreted as the end of the string.

Ah, uhm, I don't think so. 'field' is a string literal not an interpolated variable.....Anyway here is some code that proves the point and shows you how to do s/this/that/g in javascript

<script> var problem = "O'dear"; document.write( 'problem' + "<br>\n" ); problem = problem.replace( /'/g, "\\'" ); document.write( 'still' + ' no ' + problem ); </script> __DATA__ problem<BR> still no O\'dear

Now I just have to log off, log on as my alter ego and downvote myself for contaminating the hallowed ground of PM.....It was only 4 lines. Hopefully the gods will be kind.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print