Skip to content

Instantly share code, notes, and snippets.

@thomasJang
Last active November 10, 2015 02:06
Show Gist options
  • Save thomasJang/5ba2ad963b9c6b3f91b8 to your computer and use it in GitHub Desktop.
Save thomasJang/5ba2ad963b9c6b3f91b8 to your computer and use it in GitHub Desktop.
regExp replace
var url_string = "https://lh3.googleusercontent.com/-6z6mZ1jCGoA/VhVvM9dr_6I/AAAAAAAAVwU/djxcLHi-KLY/Ic42/IMG_2553.jpg";
console.log(url_string);
url_string = url_string.replace(/(\w*)[\\\/]\w*\.\w*$/, function(match, folder){
return folder + '-thomas' + match.substr(folder.length);
});
console.log(url_string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment