# Regex - Strip HTML into Plain Text with Formatting

**URL:** <https://forum.kirupa.com/t/regex-strip-html-into-plain-text-with-formatting/259079>\
**Category:** flash\
**Created:** [April 30, 2008, 10:09pm UTC](https://forum.kirupa.com/t/regex-strip-html-into-plain-text-with-formatting/259079 "2008-04-30T22:09:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nineteen](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nineteen/32/2679_2.png) [@Nineteen](https://forum.kirupa.com/u/Nineteen)\
**Post date:** [April 30, 2008, 10:09pm UTC](https://forum.kirupa.com/t/regex-strip-html-into-plain-text-with-formatting/259079/1 "2008-04-30T22:09:43Z")

</div>

Hi,

Anyone have any ideas what regular expressions to use to strip an HTML document and format it so that when it is inserted into a dynamic text field it has line breaks / formatting etc.

Eg: Atm I have two regulard expressions, one that strips white space beween tags and one that strips tags… But then there is no line breaks between paragraphs etc.

What I need is to take the \<body\> of the HTML document, replace \<br /\>, \<br\>, \<p\> tags with  
replace \<li\> tags with etc Remove all tags (including images etc) and basically just end up with the formatted text of that HTML.

Cheers,  
Ryan
