Auth_Yadis_ParseHTML::tagPattern PHP Method

tagPattern() public method

Create a regular expression that will match an opening or closing tag from a set of names.
public tagPattern ( mixed $tag_names, mixed $close, mixed $self_close ) : string
$tag_names mixed Tag names to match
$close mixed false/0 = no, true/1 = yes, other = maybe
$self_close mixed false/0 = no, true/1 = yes, other = maybe
return string $regex A regular expression string to be used in, say, preg_match.
    function tagPattern($tag_names, $close, $self_close)
    {
        if (is_array($tag_names)) {
            $tag_names = '(?:' . implode('|', $tag_names) . ')';
        }
        if ($close) {
            $close = '\\/' . ($close == 1 ? '' : '?');
        } else {
            $close = '';
        }
        if ($self_close) {
            $self_close = '(?:\\/\\s*)' . ($self_close == 1 ? '' : '?');
        } else {
            $self_close = '';
        }
        $expr = sprintf($this->_tag_expr, $close, $tag_names, $self_close);
        return sprintf("/%s/%s", $expr, $this->_re_flags);
    }