Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert .NET Regex to PCRE2 Regex to get date value of a JSON

I have JSONs which look like this:

[{"step":1,"stepId":17,"nextStepId":18,"data":[{"title":"Role of Partner","content":null,"contentText":"Please select one","type":"dropdown","id":"field2step17"}],"status":"00-Draft"},{"step":2,"stepId":18,"nextStepId":42,"data":[{"title":"Product Line","content":["116"],"contentText":"International BD","type":"lookup","id":"field2step18"},{"title":"TEST Responsible Person","content":"John, Doe (external)","key":"i:0#.w|opmain\\xespsa","type":"people-picker","id":"field3step18"},{"title":"Deadline","content":"2023-01-04","type":"date","id":"field12step18"}],"status":"00-Draft"},{"step":3,"stepId":42,"nextStepId":19,"data":[],"status":"00-Draft"},{"step":4,"stepId":19,"nextStepId":21,"data":[],"status":"00-Draft"},{"step":5,"stepId":21,"nextStepId":null,"data":[{"title":"(iii) none of the above","content":"Yes","type":"radio","id":"field3step21"}],"status":"00-Draft"},{"step":6,"stepId":16,"nextStepId":null,"data":[{"title":"The partner’s role is limited to supporting TEST Group in tax, financial, accounting, legal or regulatory advisory services or related representations before government agencies, provided that:\nthe proposed Partner is a reputable legal, audit or accounting firm; and\nthe Partner’s role does not involve acting on behalf of TEST Group in the process of obtaining or retaining contracts (whether from government or private entities)","content":"Yes","type":"yes-no","id":"field1step16"}],"status":"00-Draft"},{"step":7,"stepId":39,"nextStepId":null,"data":[],"status":"00-Draft"}]

I use this regex to get the value of Deadline (2023-01-04)

(?<=""title"":""(?i)Deadline""(?-i),""content"":"")[^""]+

However, the Regex only works for .NET. See https://regex101.com/r/GTudbU/1

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried to change to make it applicable for PCRE2, but I couldn’t figure out how.

How does the Regex need to be changed to work for PCRE2?

>Solution :

Remove the double " in the regex

(?<="title":"(?i)Deadline"(?-i),"content":")[^"]+

https://regex101.com/r/GHJVFg/1

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading