Need Help on Nifi replace text with regex

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Help on Nifi replace text with regex

Puspak
Hi Team ,

I am relatively new to Nifi regex .

i have a requirement like i have a flow file content as below .

XXXXXXXX<FLIGHT-IN>
                <FLIGHT>KH228</FLIGHT>
                <DATE>20JUN19</DATE>
                </FLIGHT-IN>YYYYYYYYY

And the expected out put is
<FLIGHT-IN>
          <FLIGHT>KH228</FLIGHT>
          <DATE>20JUN19</DATE>
</FLIGHT-IN>

i know we can achieve the same  with replace text and nifi expression
language but not sure how .

Quick help is highly appriciated.



--
Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Need Help on Nifi replace text with regex

Denes Arvay
Hi,

Just to clarify: you basically want to trim the extra characters from the
beginning and end of your XML fragment, right?

It's possible with the ReplaceText processor, with the following settings:
- search value: (?s).*(<FLIGHT-IN>.+</FLIGHT-IN>).*
- replacement value: $1
- replacement strategy: regex replace
- evaluation mode: entire text

I don't know how performant this is and if there is a better way to do
this, though.

Best,
Denes

On Tue, Jun 25, 2019 at 2:03 PM Puspak <[hidden email]> wrote:

> Hi Team ,
>
> I am relatively new to Nifi regex .
>
> i have a requirement like i have a flow file content as below .
>
> XXXXXXXX<FLIGHT-IN>
>                 <FLIGHT>KH228</FLIGHT>
>                 <DATE>20JUN19</DATE>
>                 </FLIGHT-IN>YYYYYYYYY
>
> And the expected out put is
> <FLIGHT-IN>
>           <FLIGHT>KH228</FLIGHT>
>           <DATE>20JUN19</DATE>
> </FLIGHT-IN>
>
> i know we can achieve the same  with replace text and nifi expression
> language but not sure how .
>
> Quick help is highly appriciated.
>
>
>
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
>