Anup, The Regular Expression that you are using: "[\S\s]*" can be read as "a non-space character or a space character 0 or more times." So it's really "anything 0 or more times." So when you evaluate that, it will end up matching the entire content that it's evaluated against, and then again matches 0 characters at the end, so the regular expression matches two times. If you instead changed it to "[\S\s]+" so that it matches 1 or more characters, then this should avoid the duplication.
Does this make sense? Thanks -Mark ---------------------------------------- > Date: Mon, 25 May 2015 08:51:14 -0700 > From: [email protected] > To: [email protected] > Subject: send JSON format to kafka and avoid duplication > > I have a set of files for which I need to send its filename and another > property in a JSON format (shown below) to Kafka. > > /{ > filename=${filename}, > property=${property} > } > / > > I tried to replace the entire content with the above JSON content and send > it to Kafka. But instead of obtaining values of $filename and $property, I > obtained the entire JSON content as it was.. (with duplication) > > > Then I tried replacing only ${filename} as the replacement text (shown > below) , for which I obtained the values but the duplication was still > present. > > /Property used in replaceText: > > Regular ExpressionInfo = [\S\s]* > Replacement ValueInfo = ${filename} > Character SetInfo =UTF-8 > Maximum Buffer SizeInfo = 1 MB > Evaluation ModeInfo = Entire text/ > > @Kafka consumer > > file_21.txtfile_21.txt > file_15.txtfile_15.txt > file_19.txtfile_19.txt > file.txtfile.txt > > > *So how do I > - avoid repetition? > - send it as a JSON string?* > > <http://apache-nifi-incubating-developer-list.39713.n7.nabble.com/file/n1624/putKafka.png> > > > > > -- > View this message in context: > http://apache-nifi-incubating-developer-list.39713.n7.nabble.com/send-JSON-format-to-kafka-and-avoid-duplication-tp1624.html > Sent from the Apache NiFi (incubating) Developer List mailing list archive at > Nabble.com.
