Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

Regex to replace empty curl braces in nifi

New Contributor

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!

1 ACCEPTED SOLUTION

Master Collaborator

@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.

View solution in original post

1 REPLY 1

Master Collaborator

@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.