nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <>
Subject [jira] [Commented] (NIFI-1919) Expression Language only evaluates regular expression replacement on replaceAll, not replace
Date Wed, 01 Jun 2016 23:42:59 GMT


ASF subversion and git services commented on NIFI-1919:

Commit 812731497553404161eb51100ba34f5121fffad9 in nifi's branch refs/heads/master from [~alopresto]
[;h=8127314 ]

NIFI-1919 Added replaceFirst() expression language method which accepts literal or pattern
for replacement.

Reverted whitespace changes. (+8 squashed commits)
Squashed commits:
[329755c] NIFI-1919 Reverted import re-organization from IDE.
[cf73c2f] NIFI-1919 Updated expression language guide.
[d9a1455] NIFI-1919 Reverted changes to ReplaceEvaluator.
Added ReplaceFirstEvaluator.
Added replace first logic to Query buildFunctionEvaluator.
Added unit tests.
[e2eb880] NIFI-1919 Added replaceFirst to AttributeExpression lexer and parser grammar definitions.
[11fe913] NIFI-1919 Ignored demonstrative test for replaceAll as it behaves as expected.
[af97be1] NIFI-1919 Changed ReplaceEvaluator to use String#replaceFirst which interprets regex
instead of compiling as literal.
Demonstrative unit test now passes but two existing unit tests fail. I am not sure these tests
are correct.
[f24f17b] NIFI-1919 Added working unit test to illustrate fix.
[8a0d43b] NIFI-1919 Added Groovy unit test to demonstrate issue.
Added DelegatingMetaClass code to record it (test not complete).

This closes #474.

Signed-off-by: Andy LoPresto <>

> Expression Language only evaluates regular expression replacement on replaceAll, not
> --------------------------------------------------------------------------------------------
>                 Key: NIFI-1919
>                 URL:
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 0.6.1
>            Reporter: Andy LoPresto
>            Assignee: Andy LoPresto
>             Fix For: 1.0.0, 0.7.0
> When {{${attribute:replaceAll('\w+', 'replacement')}}} is called, the pattern is matched
and applied. However, when {{${attribute:replace('\w+', 'replacement')}}} is called, it is
not. I believe this is because {{ReplaceAllEvaluator}} uses {{String#replaceAll(String regex,
String replacement)}} while {{ReplaceEvaluator}} uses {{String#replace(CharSequence target,
CharSequence replacement)}} which then uses {{Pattern.compile(target.toString(), Pattern.LITERAL)}}
instead of compiling for a regular expression. I am writing a unit test to demonstrate this
and show the results when {{String#replaceFirst()}} is used instead. 

This message was sent by Atlassian JIRA

View raw message