how to remove html tags from the text [message #684127] |
Thu, 08 April 2021 07:39  |
 |
Sekhar6617
Messages: 22 Registered: March 2021
|
Junior Member |
|
|
Hi Team,
whenever am selecting the fields from the table using sql, I was getting the HTML tags for one of the field.
Ideally it should be not shown in sql output.
Could you please help me that how to remove HTML tags from the text message.
Thank you.
Regards
Sekhar
|
|
|
|
|
Re: how to remove html tags from the text [message #684132 is a reply to message #684128] |
Thu, 08 April 2021 10:47   |
 |
Sekhar6617
Messages: 22 Registered: March 2021
|
Junior Member |
|
|
Hi Solomon,
Thank you for your response.
I have tried with REGEXP_REPLACE function but couldn't see the proper results.
select REGEXP_REPLACE('<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",scan-serif">Unified Support provides.</span></p>', '^(\S*|\W*|\d*)','') from notes_tbl;
Here I am explaining you with example. Assume NOTE_TEXT field has the content like this:
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",scan-serif">Unified Support provides.</span></p>
Ideally this happens when the user saves the entire content of email into this field. In the online pages, it is showing as proper message but when i query back-end data it is showing with HTML commands.
CREATE TABLE NOTES_TBL (
NOTE_ID int,
NOTE_NAME varchar(255),
NOTE_TEXT CLOB
);
INSERT INTO NOTES_TBL VALUES (1458, 'Warning Message',
'<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",scan-serif">Unified Support provides.</span></p>')
I should get the output as below without displaying the HTML related commands.
Result:
NOTE_ID NOTE_NAME NOTE_TEXT
1458 Warning Message Unified Support provides.
Thank you.
Regards
Sekhar
|
|
|
Re: how to remove html tags from the text [message #684135 is a reply to message #684132] |
Thu, 08 April 2021 12:17   |
Solomon Yakobson
Messages: 3214 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
SELECT NOTE_ID,
NOTE_NAME,
REGEXP_REPLACE(NOTE_TEXT,'<[^>]+>') NOTE_TEXT
FROM NOTES_TBL
/
NOTE_ID NOTE_NAME NOTE_TEXT
---------- --------------- ----------------------------------------
1458 Warning Message Unified Support provides.
SQL>
SY.
|
|
|
|
|
|
Re: how to remove html tags from the text [message #684173 is a reply to message #684171] |
Wed, 14 April 2021 23:16  |
 |
Sekhar6617
Messages: 22 Registered: March 2021
|
Junior Member |
|
|
Hi Solomon,
Yes, this is something we can do with csv file.
However, below trick worked and removed all blank lines from the text.
REPLACE(To_char(REGEXP_REPLACE(NOTE_TEXT, '<[^>]+>|\ |\n|\A','')),CHR(10),'')
Thank you.
Regards
Sekhar
|
|
|