Wrap one line paragraphs in string with h tags

Hi,
I have text (string) like this:

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.

Blah blah blah blah

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.

So, we have 3 paragraphs, made by returns and newlines (could be html <p> tags, doesnt matter, we can convert it anyway). Now, every single-line paragraph we want to wrap with <h2> and </h2> tags - make a heading from it.

How could this be done? I have no idea.

Thank you for help.

First question. What scripting language do you plan to use to achieve this? Maybe a server side script such as PHP?

Hi, yeah, right, PHP.

well assuming the text you want to transform is stored in a string variable. Something like this.

$text = "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah  blah blah blah blah blah blah blah blah blah blah blah blah blah blah  blah blah.

Blah blah blah blah

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah  blah blah blah blah blah blah blah blah blah blah blah blah blah blah  blah blah blah blah.";

$lines = preg_split('/\r\n|\r|\n', $text);
$text2 = "";
foreach($lines as $line)
{
      if($line!="")
            $text2 .= "<h2>".$line."</h2>\r\n";
}

// The text will then be stored in $text2 with the h2 tags in place
//do what you want with it say:

echo $text2;

Hope this is what you meant. Unless you meant you want to split up where there is a <p>?

Ah, OK, there may be a more complicated situation, e.g. - there is no empty line between paragraphs. There are several paragraphs and several headlines etc. I have a code now, where it splits all paragraphs and when a paragraph is shorter then given number of letters, it makes a h2 from it...

Not sure i understand exactly what you mean? Have you got some examples to show me?