Skip to content
Advertisement

Parse string in javascript

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

Advertisement

Answer

try this : 

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

g[1] will have the value

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

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement