# NUT: RegExp for finding opening HTML tag

**URL:** <https://forum.kirupa.com/t/nut-regexp-for-finding-opening-html-tag/303089>\
**Category:** flash\
**Created:** [January 13, 2010, 7:52pm UTC](https://forum.kirupa.com/t/nut-regexp-for-finding-opening-html-tag/303089 "2010-01-13T19:52:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oybrator](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/oybrator/32/1384_2.png) [@oybrator](https://forum.kirupa.com/u/oybrator)\
**Post date:** [January 13, 2010, 7:52pm UTC](https://forum.kirupa.com/t/nut-regexp-for-finding-opening-html-tag/303089/1 "2010-01-13T19:52:27Z")

</div>

I’m working with printing in flash and I need to span long articles over several pages. I have worked out a solution for finding the overflowing text for each page. But the body text in the articles are formatted with HTML and CSS, so I cannot just split the text anywhere.

Example:

bodyField.htmlText results look like this:

```auto
... <P ALIGN="LEFT"><FONT FACE="Times Roman">Morbi non lectus et purus bibendum dictum</FONT></P><P ALIGN="LEFT"><FONT FACE="Times Roman">Morbi non lectus et purus bibendum dictum</FONT></P>...

```

If now my overflow algorithm finds that this text needs to be split up at character index 52 (the character “n” in “Morbi **n** on”), then that leaves me without a closing P-tag at the current page and an opening P-tag on the next.

I would like to be able to find the character index of the “\<” character that opens the P-tag that the split point character is within. Basically I would like to match any previous instance of “\<P” before the given character index.

Any ideas, you hard core reguar expression folks out there?
