public function match($subject, &$match)
{
if (count($this->patterns) === 0) {
return false;
}
if (!preg_match($this->getCompoundedRegex(), $subject, $matches)) {
$match = '';
return false;
}
$match = $matches[0];
for ($i = 1; $i < count($matches); $i++) {
if ($matches[$i]) {
return $this->labels[$i - 1];
}
}
return true;
}
function testPatternLabels() { $regex = new ParallelRegex(false); $regex->addPattern("abc", "letter"); $regex->addPattern("123", "number"); $this->assertIdentical($regex->match("abcdef", $match), "letter"); $this->assertEqual($match, "abc"); $this->assertIdentical($regex->match("0123456789", $match), "number"); $this->assertEqual($match, "123"); }