Hi, kindly asking for a hand , here.
suppose, a simple Json object:
{"title":"Title", {"data":"Data", {"foo": "Bar"}}
and a regular expression:
(?<="foo"\ *:\ *")(?:\"|[^"])*
that matches "Bar" value.
{"title":"Title", {"data":"Data", {"foo": "Bar"}}
I have not been able to apply that in Stata
I guess I am not escaping "foo" double quotes correctly.
thanks
suppose, a simple Json object:
{"title":"Title", {"data":"Data", {"foo": "Bar"}}
and a regular expression:
(?<="foo"\ *:\ *")(?:\"|[^"])*
that matches "Bar" value.
{"title":"Title", {"data":"Data", {"foo": "Bar"}}
I have not been able to apply that in Stata
Code:
clear input str51 json `"{"title":"Title", {"data":"Data", {"foo": "Bar"}}"' end . gen str9 foo = ustrregexs(0) if ustrregexm( json ,`"(?<="foo"\ *:\ *")(?:\\"|[^"])*"') (1 missing value generated) . list +----------------------------------------------------------+ | json foo | |----------------------------------------------------------| 1. | {"title":"Title", {"data":"Data", {"foo": "Bar"}} | +---------------------------------------------------------
thanks
Comment