Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. var text = 'This is the text to replace !!value to replace!!!';
  2.  
  3. text = replaceTenuis(text, '<a href="">KEYFIND</a>', 'KEYFIND');
  4.  
  5. function replaceTenuis(toReplace, replaceWith, replaceKey) {
  6. return toReplace.replace(
  7. /(?:!{2})([\w\s\d]+)(?:!{2})/i,
  8. function(fullMatch, keyMatch) {
  9. return replaceWith.replace(replaceKey, keyMatch);
  10. });
  11. }
  12.  
  13. console.warn(text);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement