fork download
  1. var regexp = /.+?(images|videos|friends|)$/;
  2. function cb ($0, $1) {
  3. //console.log($0, $1);
  4. r = $1 ? $1 : 'profile';
  5. return '/user-' + r;
  6. }
  7. print("/john-smith-images".replace(regexp, cb));
  8. print("/john-smith-videos".replace(regexp, cb));
  9. print("/john-smith".replace(regexp, cb));
Success #stdin #stdout 0.4s 381952KB
stdin
Standard input is empty
stdout
/user-images
/user-videos
/user-profile