Skip to main content
r_rachuri
Bronze ⭐️⭐️⭐️
April 18, 2022
Solved

Regex to replace empty curl braces in nifi

Hi All,

I have a requirement where there are some empty curl braces in my JSON output which needs to be removed and replaced with empty string. The regex seems to work fine to find the braces when tested outside.

Sample can be found here:

https://regex101.com/r/AtTPv1/2

 

I tried to use this regex in nifi using replaceText, but it's not doing the replace. Below is my config for replaceText.

 

Screenshot from 2022-04-18 12-41-46.png

 

Can anyone suggest if there are any options to change to make it work or any other better alternatives for working with JSON?

Thanks in advance!

araujo
araujoAnswer
Platinum ⭐️⭐️⭐️
April 21, 2022

@r_rachuri ,

 

Your expression works for me on NiFi 1.15.2. It's too complicated, though, and it still leaves a pair of curly brackets behind.

 

Try using this one instead:

\{[ \n]*\}[ \n]*,?[ \n]*

 

Cheers,

André

 

 

-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.

1 reply

araujo
Platinum ⭐️⭐️⭐️
araujoAnswer
Platinum ⭐️⭐️⭐️
April 21, 2022

@r_rachuri ,

 

Your expression works for me on NiFi 1.15.2. It's too complicated, though, and it still leaves a pair of curly brackets behind.

 

Try using this one instead:

\{[ \n]*\}[ \n]*,?[ \n]*

 

Cheers,

André

 

 

Translate
-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.