Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR ALTER FUNCTION STR_UNHTML (
- P_SOURCE_HTML blob sub_type 1 segment size 80)
- returns blob sub_type 1 segment size 80
- AS
- DECLARE variable TAGSTART INTEGER;
- DECLARE variable TAGFINISH INTEGER;
- DECLARE variable TAGFOUND blob sub_type text;
- DECLARE variable RESULT_TEXT blob sub_type text;
- BEGIN
- -- essa procedure retorna um texto (blob) sem a porção de tags <html>, ex:
- -- ret=STR_UNHTML('<html>texto<b> sem as tags</b></html>'); // resultado: texto puro sem as tags html
- -- Util para tornar um texto HTML texto pesquisável.
- result_text='';
- p_source_html=TRIM(:p_source_html);
- tagstart = position ('<', :p_source_html);
- WHILE (:tagstart > 0) DO
- BEGIN
- tagfinish = position ('>', :p_source_html, :tagstart);
- IF (:tagfinish<:tagstart) THEN
- tagfinish=char_length(:p_source_html);
- tagfound = substring (:p_source_html FROM :tagstart FOR ((:tagfinish - :tagstart) + 1));
- p_source_html = REPLACE (:p_source_html, :tagfound, '');
- tagstart = position ('<', :p_source_html);
- END
- result_text = :p_source_html;
- RETURN result_text;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement