Converting paragraph tags with RegEx

Posted by Joel on Stack Overflow See other posts from Stack Overflow or by Joel
Published on 2010-12-29T15:30:47Z Indexed on 2010/12/29 15:54 UTC
Read the original article Hit count: 214

Filed under:
|

I need to replace all <p> tags with <br /> tags within a string. The problem is that the <p> tag can have attributes in it , such as <p align="center"> so I want to delete all occurrences of an opening tag of a paragraph, no matter what attributes are in it, and replace them with <br />.

I am using PHP and had no success getting to the right expression with the preg_replace function.

Any help would be appreciated!

Joel

© Stack Overflow or respective owner

Related posts about php

Related posts about regex