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

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -