Parse string in javascript

Robin Carlo Catacutan picture Robin Carlo Catacutan · Jan 28, 2012 · Viewed 22.8k times · Source

How can I parse this string on a javascript,

var string = "http://www.facebook.com/photo.php?fbid=322916384419110&set=a.265956512115091.68575.100001022542275&type=1";

I just want to get the "265956512115091" on the string. I somehow parse this string but, still not enough to get what I wanted.

my code:

var newstring = string.match(/set=[^ ]+/)[0]; 

returns:

a.265956512115091.68575.100001022542275&type=1

Answer

Royi Namir picture Royi Namir · Jan 28, 2012
try this : 

  var g=string.match(/set=[a-z]\.([^.]+)/);

g[1] will have the value

http://jsbin.com/anuhog/edit#source