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.

Extracttext from Json with multiple fields and ignore the other ones

Extracttext from Json with multiple fields and ignore the other ones

New Contributor

I have json object that includes the below:
 {
"x":"avc123.abc.com",
"z":"24 - ny"
}
and I would like to only target "x" value for "123" (numbers only) and the rest won't get picked up such as "z"
so the expected output would be {
"x":"avc123.abc.com",
"z":"24 - ny",
"y":"123"
}

please note that the "z" value of "24" is not being picked up. "y" value is only being picked up from  x value. 

I already done the below 

Add new property in ExtractText processor 

val

 

 

(\d+)

 

 

 -

Then use ReplaceText processor with below configs:

Search Value

}
Replacement Value
,"y":"${val}"}
Character Set
UTF-8
Maximum Buffer Size
1 MB
Replacement Strategy
Literal Replace
Evaluation Mode
Entire text

-

1 REPLY 1
Highlighted

Re: Extracttext from Json with multiple fields and ignore the other ones

Super Guru

@ANMAR 

Try with this regex in ExtractText processor.

(?:"x":.\w+?)(\d+)

This regex will extract only the digit in "x" key and adds that value for "y" key in ReplaceText processor.