For example:
{ criterion: [
{
"type":"contact_field",
"fieldType":"select", // this should match
"operator":"EQUALTO",
"value":[
{
"id":"5767",
"text":"Health/Human Services"
}
],
"id":23757,
"ruleId":22402,
"minimized":false,
"field":{
"id":"1001-456-4748",
"type":"radio" // the fieldType should match this field.type
},
"conjunction":"OR"
},
{
"field":{
"id":"1001-456-4748",
"type":"radio" // the `fieldType` above should not match this `field.type` but the one that's in its own criteria.
}
}
]
Here I have a json array representing criterion. The purpose is to make sure that fieldType
and field.type
that we are referencing to belong to the same criteria. I am trying to do this by considering they key conjunction
as discriminator since it always occurs at the end of each criteria. (Please let me know if there is a better way by using regex to tell if both the keys fieldType and field.type belong to the same json array index).
Following my approach (of considering the conjunction key here as discriminator), I want to make sure that my regex matches the fieldType
and field.type
that comes as a pair before conjunction
appears. If not, then it shouldn't match.
Things I have already tried before:
fieldType\W+select(?:(?!conjunction).){1}field.*type\W+radio$\r?\n?
- fieldType\W+select.?(?!conjunction).?type\s*"\s*:\s*"\sradio\s"
- I tried referencing examples provided here