# Truncate text between the \<p\> or \<br\> tags

**URL:** https://forum.kirupa.com/t/truncate-text-between-the-p-or-br-tags/269916
**Category:** programming
**Created:** [September 3, 2008, 3:58am UTC](https://forum.kirupa.com/t/truncate-text-between-the-p-or-br-tags/269916 "2008-09-03T03:58:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![saxx](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@saxx](https://forum.kirupa.com/u/saxx)
#### Post date: [September 3, 2008, 3:58am UTC](https://forum.kirupa.com/t/truncate-text-between-the-p-or-br-tags/269916/1 "2008-09-03T03:58:10Z")

</div>

I get how to truncate by characters,and words. But is it possible to truncate only the text between \<p\> tags, and amount of times you want to do so?

for example if i had this text

> \<p\> i eat babies \</p\>

is there a way i could preg replace only between the \<p\> tags.
