I need to extract json from a particular string which looks like this:
'loglocale=
{
"seed": "pqr",
"pageHashCode": "xxx",
"timestamp": 1553589859880,
"channel": "mobile",
"serviceVersion": "1.0",
"language": "en-CHN"
}
; regStatus=xx; s_dslv=34; s_fid=65-64748; s_vn=64678%26vn%3D1',
groups: undefined ]
I have tried this but could not extract it .
var regex=cookies.match(/{"seed":(\w|\W)*"channel":(\w|\W)*}/);
What is the solution I could use? Thanks in advance:)
'and stuff after the;actually part of the string? Do you have access to the actual JSON data? It's best to useJSON.parserather than regex if possible. You could useJSON.parse(s.match(/({.+?})/ms)[0]);if the string is verbatim as in your post.