‎2020 Feb 06 10:03 AM
Hi, am new to REGEX. Can someone suggest REGEX for the below string.
{ "HHHH": { "@H1": "11111", "@H2": "22222", "AA": [ { "@A1": "A1A1", "A2A2": "A3A3" } , { "@A2": "A1A1", "A2A2": "A3A3" } } } ], "BB": [ { "@B1": "A1A1", "A2A2": "A3A3" } , { "@B2": "A1A1", "A2A2": "A3A3" } ], "CC": [ { "@C1": "A1A1", "A2A2": "A3A3" } , { "@C2": "A1A1", "A2A2": "A3A3" } ] } }
From the above, how can I pick only "BB": [ { "@B1": "A1A1", "A2A2": "A3A3" } , { "@B2": "A1A1", "A2A2": "A3A3" } ], I have REGEX like below Find REGEX ' "BB": \{\W.*("CC") ' This is picking match like "BB": [ { "@B1": "A1A1", "A2A2": "A3A3" } , { "@B2": "A1A1", "A2A2": "A3A3" } ], "CC". How can avoid the "CC"?
‎2020 Feb 06 10:20 AM
Hi Raj,
as you are new to REGEX you may want to "play" with this SAP-provided program:
DEMO_REGEX_TOY
It explains the various REGEX options and lets you try things out.
Hope this helps!
Cheers
Bärbel
‎2020 Feb 07 3:50 AM
Hi Barbel,
Thanks, yes I tried and got this one "BB": \{\W.*("CC") ' . Still trying to find how can I avoid "CC" from the find mat
‎2020 Feb 06 11:03 AM
Hello rajsg1202,
In addition to the above response, recommend you to go through below blog as well.
Regards!
‎2020 Feb 06 1:05 PM
Hey, but it's JSON !
So, don't use Regex, parse the JSON.
See the many questions and answers in the forum.
EDIT: if you want to use a JSONpath in ABAP, sorry it doesn't exist. If you want something close, you have to convert the JSON to XML (CALL TRANSFORMATION) and use:
‎2020 Feb 07 3:39 AM
Hi Sandra,
Thanks. some of I am not timely alerts to check the answer.
My requirement is to pick up like jsonpath ( Ex: you may check in Jsonpath.com, $.phoneNumbers[:2]) . If I parse it to ABAP, further I have to pick up specific object and again parse the object to JSON (final output). Hence thought of using JSON Path.
Can you suggest if my approach is right?
Thanks,
Raj