-1

I want to convert this string

<br>
<br class="MsoNormal" align="justify" style="MARGIN: 0cm 0cm 0pt">
<br class="MsoNormal" align="justify" style="MARGIN: 0cm 0cm 0pt">
<br>
<br>
<br class="MsoNormal" align="justify" style="MARGIN: 0cm 0cm 0pt">
Content here

become

Content here

How to do it with regex ?

Mr Phi
  • 1
  • 1
    [using regex as a tool to process HTML establishes a breach between this world and the dread realm of c͒ͪo͛ͫrrupt entities.](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – shesek Aug 18 '11 at 10:02
  • 2
    Your question is not well-formed. Which programming language would you do this in? The text in your example is not consistent with the problem statement in the title of your posting. Please elaborate and reformulate. – tripleee Aug 18 '11 at 10:07
  • 1
    [You shouldn't try to parse HTML with RegEx](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – Bohemian Aug 18 '11 at 10:36
  • @shesek and Bohemian Yes absolutely, but I don't think stripping tags is parsing. – gregseth Aug 18 '11 at 13:32

1 Answers1

0

To match a tag, you can use <[^>]+>, then you can use a replacement method for each matched tag, according to the language you're using.

EDIT:

With php use:

$nohtml = preg_replace("/<[^>]+>/", "", $html);

where $html is a string containing the code you want html free.

gregseth
  • 12,952
  • 15
  • 63
  • 96