I have several blocks of text separated by at least one line break ("\r\n"). These blocks of text may have zero or more tabs ("\t") in front of them. I am trying to use preg_replace to find all the line breaks and replace them with a minium of $x number of tabs to get proper HTML tabbing.
If $x = 2;
It should turn:
<p>A paragraph.</p> <ul> <li>Element 1</li> <li>Element 2</li> </ul> <p>Another paragraph.</p> A freestanding block of text.
<p>A paragraph.</p> <ul> <li>Element 1</li> <li>Element 2</li> </ul> <!-- No tabs here because it's an empty line --> <p>Another paragraph.</p> A freestanding block of text.
I'm don't fully understand the power of regular expressions, so I'm not sure if something like this is possible. I've been using [a href=\"http://www.regular-expressions.info/characters.html\" target=\"_blank\"]this site[/a] as a resource. If there is a better one out there, I'd like to know about it. This one is faily easy to comprehend even though its organization isn't quite suited for beginners.
I'll really appreciate help anyone has to offer.