Simple Nodejs Regex: Extract text from between two strings

I'm trying to extract the Vine ID from the following URL:

https://vine.co/v/Mipm1LMKVqJ/embed

I'm using this regex:

/v/(.*)/

and testing it here: http://regexpal.com/

...but it's matching the V and closing "/". How can I just get "Mipm1LMKVqJ", and what would be the cleanest way to do this in Node?

You need to reference the first match group in order to print the match result only.

var re = new RegExp('/v/(.*)/');
var r  = 'https://vine.co/v/Mipm1LMKVqJ/embed'.match(re);
if (r)
    console.log(r[1]); //=> "Mipm1LMKVqJ"

Note: If the url often change, I recommend using *? to prevent greediness in your match.

Although from the following url, maybe consider splitting.

var r = 'https://vine.co/v/Mipm1LMKVqJ/embed'.split('/')[4]
console.log(r); //=> "Mipm1LMKVqJ"

You don't want regexp for this at all

The url module is what you want

var url = require("url");

url.parse("https://vine.co/v/Mipm1LMKVqJ/embed");

Output

{ protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'vine.co',
  port: null,
  hostname: 'vine.co',
  hash: null,
  search: null,
  query: null,
  pathname: '/v/Mipm1LMKVqJ/embed',
  path: '/v/Mipm1LMKVqJ/embed',
  href: 'https://vine.co/v/Mipm1LMKVqJ/embed' }

If you want more hand-holding

url.parse("https://vine.co/v/Mipm1LMKVqJ/embed").path.split("/")[2];
// "Mipm1LMKVqJ"