php_parser.php
protected function getCompoundedRegex()
    {
        if ($this->regex === null) {
            for ($i = 0, $count = count($this->patterns); $i < $count; $i++) {
                $this->patterns[$i] = '(' . str_replace(
                        array('/', '(', ')'),
                        array('\/', '\(', '\)'),
                        $this->patterns[$i]) . ')';
            }
            $this->regex = '/' . implode('|', $this->patterns) . '/' . $this->getPerlMatchingFlags();
        }

        return $this->regex;
    }
protected function getCompoundedRegex()
    {
        if ($this->regex === null) {
            for ($i = 0, $count = count($this->patterns); $i < $count; $i++) {
                $this->patterns[$i] = '(' . str_replace(
                        array('/', '(', ')'),
                        array('\/', '\(', '\)'),
                        $this->patterns[$i]) . ')';
            }
            $this->regex = '/' . implode('|', $this->patterns) . '/' . $this->getPerlMatchingFlags();
        }

        return $this->regex;
    }
Compounds the patterns into a single regular expression separated with the "or" operator.
Caches the regex. Will automatically escape (, ) and / tokens.

@param array $patterns    List of patterns in order.