<?php $v = "key: [value1, value2, value3]"; $pattern = "/([^\s:]+)\s*:\s*\[([^\]]*)\]/"; echo("key: " . $matches[1] . "\n"); echo("values: "); ?>
Standard input is empty
key: key
values: array(3) {
[0]=>
string(6) "value1"
[1]=>
string(6) "value2"
[2]=>
string(6) "value3"
}