Skip to content

Instantly share code, notes, and snippets.

@kai5263499
Created July 11, 2014 01:05
Show Gist options
  • Save kai5263499/7d0920e869f5657ea101 to your computer and use it in GitHub Desktop.
Save kai5263499/7d0920e869f5657ea101 to your computer and use it in GitHub Desktop.
Javascript replace on a capture group
story = story.replace(person\.go\?ID=\d+"\s*[^>]*>([^(<)]+)<\/a>/g,function() {
return 'person.go?ID='+escape(arguments[1].replace(/\./g,''))+'">'+arguments[1]+'';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment