Guest User

Untitled

a guest
Jul 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. "wordg worde wordt".replace(/[get]\b/g, function(m){
  2. if (m == 'g')
  3. return 'a';
  4. else if (m == 'e')
  5. return 'b';
  6. else
  7. return 'c';
  8. });
  9.  
  10. // Alternative
  11. var map = {
  12. 'g' : 'a',
  13. 'e' : 'b',
  14. 't' : 'c'
  15. };
  16.  
  17. "wordg worde wordt".replace(/[get]\b/g, function(m){return map[m]});
  18. // returns "worda wordb wordc"
Add Comment
Please, Sign In to add comment