Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Regex to replace all characters after " ;" in a string in a flowfile - NiFi

Solved Go to solution
Highlighted

Regex to replace all characters after " ;" in a string in a flowfile - NiFi

New Contributor

Hi,

Am trying to replace all characters after ";" including ; in the flowfile record.

I was using replacetext processor with ;.*$ as the search value and set empty value for Replacement value properties to achieve this. However it is not working out.

Any inputs in this regard would be really helpful.


Example:


Input

Replace;text;processor

Expected Output:

Replace

Thanks,

Bala.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Regex to replace all characters after " ;" in a string in a flowfile - NiFi

Master Guru

@Bala S

I would recommend using capture groups in your regex. Here is an example that will work for your example:

106450-screen-shot-2019-02-19-at-91026-am.png

I then replace with just the value from capture group 1

-

Here is another example that is more generic (can have many ";<somevalue>" after first one:

106471-screen-shot-2019-02-19-at-91344-am.png

Here again I use capture group 1 as my replacement value.

-

Thank you,

Matt

-

If you found this answer addressed your question, please take a moment to login in and click the "ACCEPT" link


2 REPLIES 2

Re: Regex to replace all characters after " ;" in a string in a flowfile - NiFi

Master Guru

@Bala S

I would recommend using capture groups in your regex. Here is an example that will work for your example:

106450-screen-shot-2019-02-19-at-91026-am.png

I then replace with just the value from capture group 1

-

Here is another example that is more generic (can have many ";<somevalue>" after first one:

106471-screen-shot-2019-02-19-at-91344-am.png

Here again I use capture group 1 as my replacement value.

-

Thank you,

Matt

-

If you found this answer addressed your question, please take a moment to login in and click the "ACCEPT" link


Re: Regex to replace all characters after " ;" in a string in a flowfile - NiFi

New Contributor

Thanks @Matt Clarke. I went with the option 2 and it worked. Thanks again for the quick reply.

Don't have an account?
Coming from Hortonworks? Activate your account here