如何提取方括号之间的单词


How extract words between square brackets?

我有一个字符串,格式如下:

[ GroupOne : 2015 | 10/12 | A ] && [ GroupTow : 2015 | 10/20 | C ] && [ GroupThree : 2015 | 10/15 | B ]

通过preg_match 提取第一个方括号内的第一个单词

//Only the first part
$Number_Group //GroupOne
$Yers = //2015
$Data = //10/12
$Type = //A

不具有preg匹配,但它可以

<?php
    $cad = "[ GroupOne : 2015 | 10/12 | A ] && [ GroupTow : 2015 | 10/20 | C ] && [ GroupThree : 2015 | 10/15 | B ]";
    $values = explode('&&', $cad);
    $part1 = explode(':', substr(trim($values[0]), 1, -1));
    $Number_Group = $part1[0];
    echo $Number_Group . '<br/>';
    $other = explode('|', $part1[1]);
    $Year = $other[0];
    echo $Year . '<br/>';   
    $Data = $other[1];
    echo $Data . '<br/>';   
    $Type = $other[2];
    echo $Type . '<br/>';   
    ?>