Potential fix for issue #507 - escape string literals in js regex

Needs testing, will ask issue submitter of #507