3

I have column in a table which contains HTML text(data contains HTML tags) and also normal text.

I need to remove the HTML tags in the data wherever it exists.

Steps I planned:

  1. Filter only the records which contains HTML tags. --> I am able to complete this step. My Logic: where HTMLStirng like('<%>%')
  2. Replace HTML tags with a blank space. --> I am trying to apply replace function. But I am not able to.

For Example:

<p>Paragraph</p>
<b>bold</b><I>Italic</I>
Normal Text

My Output shold be:

Paragraph
BoldItalic
Normal Text

Can someone help me in the step 2 ?

4
  • 2
    I removed the incompatible database tags. Tag your questions only with the database you are actually using. Commented Apr 23, 2017 at 13:05
  • This is crazy and deep in XY territory. Commented Apr 23, 2017 at 13:09
  • I am trying to apply replace function. But I am not able to. ...why didn't those replacements work for you? Commented Apr 23, 2017 at 13:10
  • which database are you using, sql server or oracle or anything else? Commented Apr 23, 2017 at 13:15

1 Answer 1

4

If you are using Oracle, try the following

SELECT Regexp_replace(your_column_name, '<.+?>') 
FROM   dual;

Example

SELECT Regexp_replace('<b>bold</b><I>Italic</I> Testing', '<.+?>') 
FROM   dual;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.