in reply to Re: HTML String Parsing
in thread HTML String Parsing

this will break if they put spaces on the blank lines and also probably won't work right if they're on a platform that sends \n\r instead of just \n.

i usually use something like:

$comment = "<p>" . (join '</p><p>', grep {!/^\s+$/} split /[\n\r]+/, $comment) . "</p>";

which could be adapted to use <br> instead of <p> tags if you prefer.

anders pearson

Replies are listed 'Best First'.
Re: HTML String Parsing
by Ionizor (Pilgrim) on Dec 10, 2001 at 02:10 UTC

    Awesome! Thanks! That worked beautifully. I ended up using:

    $comment = (join "\n<BR>", grep {!/^\s+$/} split/[\n\r]+/, $comment);