protected function getOperatorRegex() {
$operators = array_merge(array(
'=',
), array_keys($this->env
->getUnaryOperators()), array_keys($this->env
->getBinaryOperators()));
$operators = array_combine($operators, array_map('strlen', $operators));
arsort($operators);
$regex = array();
foreach ($operators as $operator => $length) {
// an operator that ends with a character must be followed by
// a whitespace or a parenthesis
if (ctype_alpha($operator[$length - 1])) {
$regex[] = preg_quote($operator, '/') . '(?=[\\s()])';
}
else {
$regex[] = preg_quote($operator, '/');
}
}
return '/' . implode('|', $regex) . '/A';
}