Hi Eric,

I did some quick tests, replaceRegex works well for me. The regex patterns
should behave as expected (see:
https://github.com/apache/nifi/blob/master/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/ReplaceRegex.java#L49-L49),
I don't see any reason why it doesn't work for you.

Side note: if you want to trim both leading and trailing white spaces I'd
suggest to use the trim() function: switch to Literal Value replacement
strategy and use "${field.value:trim()}", my gut feeling is that it'd
perform better.

Best,
Denes

On Sun, Mar 17, 2019 at 8:10 PM Eric Chaves <e...@uolet.com> wrote:

> Hi Folks,
>
> Forgive me for this dummy question but  I've been cracking my head for
> hours.
>
>  Is there anything special in RecordPath regular expressions? I'm trying
> to trim whitespaces by using UpdateRecord (with replacement strategy of
> Record Path Value ) replaceRegex over current field value but I can't find
> any expression that works.
>
> All my attempts produce an output with the original value however simple
> replacements like replaceRegex(/FULL_NAME,'JON', 'ERIC' ) works. I've
> already tried expressions like:
>
> replaceRegex(/FULL_NAME,'\s', '' )
> replaceRegex(/FULL_NAME,'\s+', '-' )
> replaceRegex(/FULL_NAME,'\s{2,}', '-' )
> replaceRegex(/SSN,'(\d+)', '$1' )
> replaceRegex(/SSN,'\s+$', '' )
>
> If I try the regex in a java regex tester (like
> https://www.freeformatter.com/java-regex-tester.html) all expressions
> matches/replaces as expected but in the UpdateRecord processor they have no
> effect.
>
> What am I missing?
>
> Thanks
>

Reply via email to