Strip html using PLSQL

create or replace function striphtml(
    p_html in varchar2)
    return varchar2
is
    l_html varchar2(32767);
    l_pos pls_integer;
begin
    if length(p_html) > 0 then
        l_html := p_html;
        loop
            l_pos := regexp_instr(l_html, '<[^<>]*>');
            if l_pos > 0 then
                l_html := regexp_replace(l_html, '<[^<>]*>', null, l_pos);
            else
                exit;
            end if;
        end loop;
    end if;

   return l_html;
end striphtml;


select striphtml ('<h1> <span>Hello</span></h1>') strip, '<h1> Hello</h1>' plane from dual;

Strip Plane
Hello <h1> Hello</h1>

comments powered by Disqus