Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "wordg worde wordt".replace(/[get]\b/g, function(m){
- if (m == 'g')
- return 'a';
- else if (m == 'e')
- return 'b';
- else
- return 'c';
- });
- // Alternative
- var map = {
- 'g' : 'a',
- 'e' : 'b',
- 't' : 'c'
- };
- "wordg worde wordt".replace(/[get]\b/g, function(m){return map[m]});
- // returns "worda wordb wordc"
Add Comment
Please, Sign In to add comment