$re = '~(?xx) # all whitespaces are ignored in the pattern except between \Q and \E
# Definition
(?<item> # subpattern that forbids commas and allows balanced square brackets
[^ ][, ]* (?: \[ \g<item> ] [^ ][, ]* )*+
){0}
# Main pattern
(?:
\G (*negative_lookahead: \A ) ,
|
\QnewProductsInfo: [\E
(*:FIRST_ITEM) # add a marker to know when a new list starts
(*SKIP) (*positive_lookahead: \g<item> (?: , \g<item> )*+ ] ) # check the syntax
)
\K # discard all that has been matched before from the match result
\g<item> # a simple item followed by a comma
(?: , \g<item> (*positive_lookahead: ] ) )? # eventual trailing item
~';
$str = 'newProductsInfo: [[1] - $2 dollars,[2] New Product,[3] Hello,[4]Same, [5]Value] , other things
newProductsInfo: [[$39 OFF] - Slytherin Snake Ear Cuffs - Low in Stock,FREE Mystery Box (Previously $30),The Jewelry Club: Exclusive VIP,[Exclusive Offer] / Discounted Mystery Box]';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php