[
https://issues.apache.org/jira/browse/NIFI-9490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17465801#comment-17465801
]
Mark Payne commented on NIFI-9490:
----------------------------------
[~ahmedshaaban1999] yeah - fair. If you use Regex Replacement and match using
{{.*}} as the search value, you could reference {{$1}} via EL and do roughly
the same thing. But there are a few problems with that approach:
* It's very non-intuitive and non-obvious that you'd need to use a regex to
match the entire line/text. This should make it much clearer how to achieve
this.
* Evaluating a regex such as {{.*}} or {{.+}} is very expensive! It would be
much cheaper/more efficient to simply place the contents into a variable named
{{{}text{}}}.
* There's no way to reference the line number, which can often be important -
for instance, you may want to use something like {{${lineNo:equals(1):ifElse(
${text:toUpper()}, ${text} )} }} in order to capitalize only the first line,
etc.
> Add a 'Use Expression Language' Replacement Strategy to ReplaceText
> -------------------------------------------------------------------
>
> Key: NIFI-9490
> URL: https://issues.apache.org/jira/browse/NIFI-9490
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Extensions
> Reporter: Mark Payne
> Priority: Major
>
> When we have data that requires multiple transformations, the typical
> solution is to chain together multiple instances of ReplaceText. But this is
> expensive. It has to read & write the content multiple times. We also have to
> use Regex and are limited in the types of transformations that we can perform.
> We should add a new Replacement Strategy of "Use Expression Language." When
> selected, the Search Value should be ignored (and should be hidden via
> dependent properties). The Replacement Value should allow for Expression
> Language and should be provided FlowFile attributes as well as a variable
> named text that is to be evaluated. If the Evaluate Mode is Line-by-Line, it
> should also be provided a variable named lineNo that indicates the 1-based
> line number that is being evaluated.
> This allows for powerful transformations, such as:
> {\{ ${text:toUpper()} }} to make the line uppercase
> {\{ ${lineNo}: ${text} }} to prepend each line of text with a line number
> followed by a colon
> And many other possibilities that are not easily available today.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)