Support Questions
Find answers, ask questions, and share your expertise

How to parse a record having multi-character delimiter in NiFi?

I have a scenario where the records are having multi-character delimiter as shown below,

1$$John Wright$$New Zealand

I need to fetch the value of the second field(John Wright).

Is there any function/processor to parse multi-character delimiter record?

Currently I am replacing the multi-character delimiter($$) with single delimiter($) using ReplaceText processor & parsing the value. Is there a better approach?


I think ReplaceText processor is a good fit for this use case.

Thanks Rajkumar!!!


@Rohit Ravishankar

I think the easiest option is probably going to be replaceText, and then use either ExtractText, or NiFi Expression Language.

After your replaceText (fixing delimiter) processor, you could use Nifi Expression Language (getDelimitedField) and specify your new delimiter to get the exact file you need, and also trim if needed like so:

If your record contains:

1$John Wright$New Zealand

${record:getDelimitedField(2, '$')}

This would return "John Wright". You could also do this to trim if needed as well:

${record:getDelimitedField(2, '$'):trim()}

Thanks Devin!!! I also did the same.