Here's my regex:
((?<="StartDate":")\d{4}-\d{2}-\d{2}(?=.+"Status":"(B|C)"))
I am trying to filter the JSON below to show only the start date value of records with Status = B or C but my regex returns all statuses including those with Status not equal to B or C.
I used a regex testing site and saved my current progress here: https://regexr.com/58314
JSON:
[{"RowNumber":1,"PeriodNumber":0,"StartDate":"2023-10-18","EmployeeCompany":"0A","FirmName":"Company 1","EmpStatus":"X","TKGroup":"AR","Status":"A","StatusDesc":"In Progress"},{"RowNumber":2,"PeriodNumber":0,"StartDate":"2021-01-01","EmployeeCompany":"0A","FirmName":"Company 2","EmpStatus":"Y","TKGroup":"AR","Status":"B","StatusDesc":"Submitted"},{"RowNumber":3,"PeriodNumber":0,"StartDate":"2020-01-01","EmployeeCompany":"0A","FirmName":"Company 3","EmpStatus":"Z","TKGroup":"AR","Status":"C","StatusDesc":"Rejected"},{"RowNumber":4,"PeriodNumber":0,"StartDate":"2019-10-18","EmployeeCompany":"0A","FirmName":"Company 4","EmpStatus":"A","TKGroup":"AR","Status":"A","StatusDesc":"In Progress"}]
Expected: (both dates falls the criteria where Status = B or C))
2021-01-01
2020-01-01
Actual: (first date (2023-10-18) should not be captured as its status is = A, I was able to eliminate the other date with Status = A but not the first one.)
2023-10-18
2021-01-01
2020-01-01
I just did a minor change.
((?<="StartDate":")\d{4}-\d{2}-\d{2}(?=","Status":"(B|C)"))
Replaced .+
with ",
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.