Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

how to replace quotes at particular place in xml ?

how to replace quotes at particular place in xml ?

<tag key="value">des1"</tag><tag >description desc "des1" dsc</tag>

I want to replace quotes which are in tag <> " " </> used with des1. Here we know that des1 so we can easily replace quotes by specifying des1 but what if we don't know the name and we have to remove these quotes .? . I have tried many regEx with replaceText processor in nifi but it didn't work because it also replaces the quotes of value . I Just want to replace the quotes of des1.

note: here I have specified des1 but I want regEx which are suitable for all kind of word

2 REPLIES 2

Re: how to replace quotes at particular place in xml ?

Super Guru
@umang s

Try with below REGEX to replace ""(quotes) in <tag>

ReplaceText Configs:

Search Value

(.*).+"(.*)"(.*)

Replacement Value

$1 $2 $3

Character Set

UTF-8

Maximum Buffer Size

1 MB //increase this size according to your flowfile size

Replacement Strategy

Regex Replace

Evaluation Mode

Entire text

Input:

<tag key="value">des1"</tag><tag >description desc "des1" dsc</tag>

Output:

<tag key="value">des1"</tag><tag >description desc des1  dsc</tag>

As we have replaced quotes in des1.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

Re: how to replace quotes at particular place in xml ?

delete.xml

I have attached xml file in which I want to remove quotes from two tags and name of tag is <Department> and <LegalDisclaimer>.

Don't have an account?
Coming from Hortonworks? Activate your account here