javascript - Convert string from regexp match into object -
i have following string:
var str = 'jfkdjffddf{aaa:12,bbb:25}kfdjf';
and want fetch object it:
var objstr = str.match('/{(.*?)}/')[1]; // aaa:12,bbb:25
now want use fetched string object:
var obj = json.parse('{' + objstr + '}');
do operations on it, convert string again , replace in initial text.
the problem unexpected token a
on 1 line in script, problem json.parse
.
what's problem, , how can solve this?
Comments
Post a Comment