Extract and Create Property in JSON file with RegEx -


i have following json file. dotted across file following:

"properties": {     "name": "darlington",     "description": "<br><br><br> <table border=\"1\" padding=\"0\"> <tr><td>ccgcode</td><td>00c</td></tr> <tr><td>ccgname_short</td><td>darlington</td></tr>" } 

using regex, extract ccg code property , add in above becomes:

"properties": {     "name": "darlington",     "ccgcode": "00c",     "description": "<br><br><br> <table border=\"1\" padding=\"0\"> <tr><td>ccgcode</td><td>00c</td></tr> <tr><td>ccgname_short</td><td>darlington</td></tr>" } 

i've tried sorts , can't work. using sublime text.

^("description":").*?<td>ccgcode<\/td><td>([^<>\n]*).*$ 

the above selects code, not sure how can create property.

try this

( *)"description".*?ccgcode.*?<td>([^<]+) 

regex demo

this 1 sublimetext3

find what:

( *)("description".*?ccgcode.*?<td>)([^<]+) 

replace with:

\1"ccgcode": "\3",\n\1\2 

demo


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -