public static function remove_attributes($tag, $attrname) {
        if (is_array($attrname)) {
            $attrname = join('|', $attrname);
        }
        while (preg_match('/^(<[^>]*\b)(' . $attrname . ')=".*?"(.*)$/is', $tag, $matches)) {
            $tag = $matches[1] . $matches[3];
        }
        while (preg_match('~^(<[^>]*\b)(' . $attrname . ')([ />].*)$~is', $tag, $matches)) {
            // Some attributes may not have value, for example: <video controls>.
            $tag = $matches[1] . $matches[3];
        }
        return $tag;
    }