function parse($string)
{
$n = preg_match_all($this->parse, $string, $matches, PREG_OFFSET_CAPTURE);
$sets = array();
foreach ($matches[1] as $match) {
$sets[] = $match[0];
}
$offset = $matches[0];
$strings = array();
for ($i = 0; $i < $n; $i++) {
$len = strlen($offset[$i][0]);
$begin = $i == 0 ? $len : $offset[$i][1] + $len;
$end = $i == $n - 1 ? strlen($string) : $offset[$i + 1][1];
$strings[] = substr($string, $begin, $end - $begin);
}
return array($sets, $strings);
}