Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function exchange(str, a, b) {
- return str.split(a).map(function(item){return item.replace(new RegExp(b, 'g'), a)}).join(b);
- }
- function safeSingleQuote(str) {
- str = exchange(str, "'", '"');
- return exchange(JSON.stringify(str), "'", '"');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement