<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: ReplaceText Processor not processing all Expresssion Language in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/ReplaceText-Processor-not-processing-all-Expresssion/m-p/189291#M151384</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/70448/xlammertink.html" nodeid="70448" target="_blank"&gt;@Xander L&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Method1:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can add new extract text processor before replace text processor and keep the whole content of the flowfile as attribute and use the extracted attribute in Replace Text processor to get escapeJson function.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Extract text Processor Configs:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65391-extracttext.png" style="width: 1865px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18567iC2A8294C3DA7E6F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65391-extracttext.png" alt="65391-extracttext.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Add new property by clicking on + sign at top right corner&lt;/P&gt;&lt;P&gt;in my case i have added extract property with below regex&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;extract
&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;(.*)&lt;/PRE&gt;&lt;P&gt;Now we are going to extract all the content of the flowfile and keep that content as extract attribute to the flowfile.&lt;/P&gt;&lt;P&gt;You need to increase the below properties sizes if you are having big content to extract&lt;/P&gt;&lt;P&gt;Maximum Buffer Size&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1 MB&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Maximum Capture Group Length&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1024&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Output from extract text processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65393-output-extracttext.png" style="width: 1770px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18568iBFF91C809BD7F316/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65393-output-extracttext.png" alt="65393-output-extracttext.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Replace text Configs:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65392-replacetext.png" style="width: 1652px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18569i1B6111FBA46FF2C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65392-replacetext.png" alt="65392-replacetext.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Change the configs according to the screenshot,&lt;/P&gt;&lt;P&gt;Search Value&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;(?s)(^.*$)&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Replacement Value&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${extract:escapeJson()}&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Character Set&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;UTF-8&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Maximum Buffer Size&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1 MB //needs to change if the size of flowfile is more than 1 MB&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Replacement Strategy&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Always Replace&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;Evaluation Mode&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Entire text&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Now we are applying escapeJson function to the extract attribute as a replacement value.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Output:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;https 2018-03-18T23:55:36.990541Z app\/abc-pxx-p001\/abc123 12.34.56.78:12345 87.65.43.21:80 0.000 0.092 0.000 200 200 1124 364 \"GET https:\/\/mysite.nl:443\/test HTTP\/1.1\" \"abc\/1 CFN\/987 Darwin\/12.3.4\" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 arn:aws:elasticloadbalancing:eu-west-1:012345679:targetgroup\/abc-external-abc-de\/abc123def456 \"Root=1-5a-d2a18df071c\" \"mysite.nl\" \"session-reused\" 0&lt;/PRE&gt;&lt;P&gt;(or)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Method2:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;By using two Replace text processor in series we can have same expected result instead of using extract text processor.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Replace / with \/:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Search Value&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;/&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Replacement Value&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;\/&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Character Set&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;UTF-8&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Maximum Buffer Size&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1 MB&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Replacement Strategy&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Literal Replace&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Evaluation Mode&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Entire text&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65394-replacetext-1.png" style="width: 1546px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18570i2154CB18CBAD1264/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65394-replacetext-1.png" alt="65394-replacetext-1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;in this processor we are searching for / &lt;STRONG&gt;literal&lt;/STRONG&gt; and replacing / with \/.&lt;/P&gt;&lt;P&gt;feed the&lt;STRONG&gt; success&lt;/STRONG&gt; relation from this &lt;STRONG&gt;replacetext processor to the next replace text processor&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Replace text processor 2 for replace " with \":-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65395-replacetext-2.png" style="width: 1535px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18571i1782BAAAEE824E94/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65395-replacetext-2.png" alt="65395-replacetext-2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Search Value&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;"&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Replacement Value&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;\"&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Character Set&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;UTF-8&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Maximum Buffer Size&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;1 MB&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Replacement Strategy&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Literal Replace&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Evaluation Mode&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Entire text&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;In the next replace text processor we are searching for " and replacing " with \" by using literal replace as Replacement strategy.&lt;/P&gt;&lt;P&gt;Output flowfile content from second replace text processor will be same as our method 1.&lt;/P&gt;&lt;PRE&gt;https 2018-03-18T23:55:36.990541Z app\/abc-pxx-p001\/abc123 12.34.56.78:12345 87.65.43.21:80 0.000 0.092 0.000 200 200 1124 364 \"GET https:\/\/mysite.nl:443\/test HTTP\/1.1\" \"abc\/1 CFN\/987 Darwin\/12.3.4\" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 arn:aws:elasticloadbalancing:eu-west-1:012345679:targetgroup\/abc-external-abc-de\/abc123def456 \"Root=1-5a-d2a18df071c\" \"mysite.nl\" \"session-reused\" 0&lt;/PRE&gt;&lt;P&gt;Both ways we are getting same expected result, choose the way which can better fit for your case.&lt;/P&gt;&lt;P&gt;Let us know if you are having any issues..!!&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer,&lt;/STRONG&gt; That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 07:44:35 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T07:44:35Z</dc:date>
  </channel>
</rss>

