Reputation: 391
Beginner RegExp question. I have a JSON in my NiFi ExtractText and there are 2 fields I want to extract. How would I use a regex to do this?
[
{
"id": "12erf3-312331-233"
},
[
{
"id": "1234",
"id2": "1234",
"id3": "1234"
},
{
"id": "1234",
"id2": "1234",
"id3": "1234"
},
{
"id": "1234",
"id2": "1234",
"id3": "1234"
},
{
"id": "1234",
"id2": "1234",
"id3": "5555"
}
]
]
Upvotes: 0
Views: 383
Reputation: 1311
To achieve what you need you may use ReplaceText processor. Have a look to the configuration below. Search Value would be (?s).*("id": )(".*").*}.*(\[.*\]).*\]
and the Replacement Value: {$1$2,data:$3}
. Pay attention to pick Evaluation Mode as "Entire text".
To easily check regex you can use link i have used: https://regex101.com/r/p6T2Vw/1
Upvotes: 3