I need some regex help. I want to explode as string by a given delimiter (this could change) but in this case a comma. But only, if that comma is not in between square brackets
Here is my example string :
name:in:['john','jane'],name:in:['doe']
My desired outcome :
Array(
[0] => name:in:['john,'jane']
[1] => name:in['doe']
)
I feel i'm close but this is not quite working :
$filters = preg_split("~$delimiter(?![^[]]*\))~", $filters);
Current output :
Array
(
[0] => name:in:['john'
[1] => 'jane']
[2] => name:in:['doe']
)
It would be great if someone could help, but also explain the regex by breaking it down into its parts.