Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-1919

Expression Language only evaluates regular expression replacement on replaceAll, not replace

    XMLWordPrintableJSON

    Details

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alopresto Andy LoPresto
                Reporter:
                alopresto Andy LoPresto
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: