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.

Parsing the string and extracting the required value using regular expression

Parsing the string and extracting the required value using regular expression

New Contributor

I would like to extract the value from the regular expression match as per the below example. can any one help me if it is possible to extract the same with regular expression

1) String: xxxx&testkey=testvalue

2) string: xxxx&testkey=testvalue&

3) string: xxxx&testkey=testvalue&dfdsgskj

If I get the input text comes as any of the above formats. I need to extract testkey as testvalue.

If the input can be of types xxxx&testkey=testvalue (or) xxxx&testkey=testvalue&. I can extract testkey using .*&(.*?)&?

How can I handle the case if the format xxxx&testkey=testvalue&dfdsgskj also comes as an input?

1 REPLY 1

Re: Parsing the string and extracting the required value using regular expression

Contributor

Have you tried out:

testkey=(\w+)