mysql 去除标签函数

mysql 去除标签函数

    DELIMITER $$

    USE `blog`$$

    DROP FUNCTION IF EXISTS `strip_tags`$$

    CREATE DEFINER=`root`@`%` FUNCTION `strip_tags`($str TEXT) RETURNS TEXT CHARSET utf8
    BEGIN
        DECLARE $START, $END INT DEFAULT 1;
        LOOP
            SET $START = LOCATE("<", $str, $START);
            IF (!$START) THEN RETURN $str; END IF;
            SET $END = LOCATE(">", $str, $START);
            IF (!$END) THEN SET $END = $START; END IF;
            SET $str = INSERT($str, $START, $END - $START + 1, "");
        END LOOP;
    END$$

    DELIMITER ;