Support Questions

Find answers, ask questions, and share your expertise

Parameterizing ReplaceText Processor

Hi Team,

I am trying to parameterize 'Search Value' & 'Replacement Value' properties in ReplaceText processor. However, I am not getting the desired result.

search_pattern - ^(.{1})(.{2})(.{18})(.{19})

replace_pattern - $1|$2|$3|$4

If I use the parameters 'search_pattern' & 'replace_pattern'(${search_pattern} & ${replace_pattern}), replace is not happening. However, if I hardcode the patterns, the search & replace is happening as expected.

Could you please help me out?

Thanks!

9 REPLIES 9

@Rohit Ravishankar

To use them that way, those have to be attributes of the flow file you're passing through the ReplaceText processor.

@Wynner

I am passing them as flow file attributes only. But still I am not able to parse it properly.
Could you please check and help me out?

Thanks in Advance!

@Rohit Ravishankar

What is the configuration of the ReplaceText processor?

@Wynner

ReplaceText Configuration -

34511-replacetext.png

where search_pattern - ^(.{1})(.{2})(.{18})(.{19}) & replace_pattern - $1|$2|$3|$4

Thanks!

@Rohit Ravishankar

Do you have sample of text you can give you're working with?

@Wynner

Attached the sample data. The total length of the record is 40. We are trying to convert the fixed width data to delimited data using regex.

sample-data.txt

Thanks!

@Rohit Ravishankar

After consulting an engineer @mpayne, the way you are trying to use the attributes will not work. Attributes are treated as literals not regexes.

@Wynner

Is there a way to overcome it? Any alternate way to parameterize?

@Rohit Ravishankar

Currently there is not a way to parametrize these properties.