Reputation: 15237
I have a massive JSON file and inside it, there is a lot of this:
"Description":"<br><br><br> <table border=\"1\" padding=\"0\"> <tr><td>CCGcode</td><td>00G</td></tr> <tr><td>CCGname</td><td>NHS Newcastle North and East CCG</td></tr>"
"Description":"<br><br><br> <table border=\"1\" padding=\"0\"> <tr><td>CCGcode</td><td>00J</td></tr> <tr><td>CCGname</td><td>NHS North Durham CCG</td></tr>"
The above is surrounded with a lot of other stuff, similiar to this. I would like to replace any such occurrences with:
"Description":"NHS Newcastle North and East CCG"
"Description":"NHS North Durham CCG"
But I do not know how to. I've tried multiple Regular Expressions, but couldn't get it to work.
Upvotes: 0
Views: 396
Reputation: 174706
Use capturing groups to capture the text you want for later use.
Regex:
^("Description":").*<td>([^<>\n]*).*$
OR
^("Description":").*?<td>CCGname<\/td><td>([^<>\n]*).*$
Replacement string:
$1$2"
Upvotes: 1
Reputation: 425033
If your tool supports look behinds:
(?<="Description":").*?CCGname</td><td>(.*?)<.*
Replace with $1
Upvotes: 0