Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertHTML(str) {
- // create an object with key:value pair as char:HTML entities
- var htmlConv = {"&":"&", "<":"<", ">": ">",'\"':""","\'":"'" };
- for (var key in htmlConv){
- str=str.replace(new RegExp(key,"g"), htmlConv[key]);
- }
- return str;
- }
- convertHTML('Stuff in "quotation marks"');
Add Comment
Please, Sign In to add comment