in reply to catching newlines from textarea input
use strict; use warnings; sub ubb_txt { my $txt = shift; return "" unless ( defined $txt); my ($nl) = $txt =~ m{(\cM?\cJ)}; $txt =~ s{$nl$nl}{</p><p>}gs if (defined $nl); $txt =~ s{$nl}{<br>}gs if (defined $nl); $txt; } my $test = <<'--'; One fish Two fish Red fish Blue fish -- print ubb_txt ($test), "\n"; __END__ One fish<br>Two fish</p><p>Red fish<br>Blue fish<br>
Seems like the first regexp isn't eating all the newlines.
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: catching newlines from textarea input
by maksl (Pilgrim) on Feb 28, 2003 at 11:59 UTC | |
by Abigail-II (Bishop) on Feb 28, 2003 at 12:04 UTC | |
by maksl (Pilgrim) on Feb 28, 2003 at 12:31 UTC |