Dividir, regex u obtener valor de JSON

I have the following string / JSON:

Object {id-##: "##"}

Well, I want the digits from the JSON value. How can i get it?

saludos

preguntado el 28 de mayo de 14 a las 14:05

2 Respuestas

var nums = 'Object {id-##: "##"}'.match(/\d+/g);

The above will do.

\d+ matches digits

contestado el 28 de mayo de 14 a las 14:05

You can parse your json and then treat the values as you wish

var decoded = JSON.parse({id-##: "##"});


for(var in decoded){

   //decoded.var = "##"
   //var = "id-##"

}

contestado el 28 de mayo de 14 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.