Skip to content

Instantly share code, notes, and snippets.

@DC3
Created April 28, 2013 20:14
Show Gist options
  • Save DC3/5478249 to your computer and use it in GitHub Desktop.
Save DC3/5478249 to your computer and use it in GitHub Desktop.
'wkjkjd fsk fsdjk\nbbb sss fasdf'.replace(/(bbb|sss)(\s)?/g, function(match, p1, p2){
var min = 1, max = p1.length - 1,
pos = Math.floor(Math.random() * (max - min + 1)) + min; //randint
return p1.substr(0, pos) + 'a' + p1.substr(pos, p1.length - 1) + p2;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment