We use the javascript window.setTimeout method for a recursive call of a function with certain parameters. Because the function call has to be constructed by string concatenation, we have to escape potential quotes inside the parameters. After some regex headache we came up with the following generic solution:

function escapeQuotes(value) {
   value = value.replace(/([^\\])'|^'/g, "$1\\'");
   return value.replace(/([^\\])"|^"/g, "$1\\\"");
}

Feel free to use it or simply test your regex reading capabilities.

Email this Share this on Facebook Share this on LinkedIn Tweet This! RSS feed for comments on this post. TrackBack URL

Leave a comment