Guest User

Untitled

a guest
Oct 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. function convertHTML(str) {
  2. // create an object with key:value pair as char:HTML entities
  3. var htmlConv = {"&":"&", "<":"<", ">": ">",'\"':""","\'":"&apos;" };
  4. for (var key in htmlConv){
  5. str=str.replace(new RegExp(key,"g"), htmlConv[key]);
  6.  
  7. }
  8. return str;
  9. }
  10. convertHTML('Stuff in "quotation marks"');
Add Comment
Please, Sign In to add comment