Hello, all,
I'm trying to translate the value entered in a
TEXTAREA tag to one or more HTML paragraphs. That
means any newlines entered into the text box need to
be turned into P tags by the script. But I'm having
trouble coming up with a regex to do this. I know I
need multiline mode, so I've been trying combinations
involving "s/$/<p>/mg" or "s/^/<p>/mg", but nothing
has worked so far. Everything I've tried has (1) added
the P tag but not removed the newline, and/or (2) also
added one at the end of the string (using $, or at the
beginning using ^) even though there's not a newline
there. The latter seems to be by Perl design, but I
don't want it in this case.
Here's the test program I'm using to experiment
(warning to HTML email clients, there is an HTML tag
in this code):
my $lf = chr(10);
my $Text = "Para.${lf}Para.${lf}Para.";
$Text =~ s/$/<p>/mg;
print $Text;
And a follow-up question: When newlines are entered
into a TEXTAREA, is TEXTAREA standardized to use CR/LF
pairs, or just CR, just LF, or does it depend on the
client and/or the server platform? Do we need to worry
about this? Or will the ^ and $ characters work
correctly with any of these combinations so we don't
need to worry about it?
Thanks in advance for any help.
- John
=====
"When you're following an angel, does it mean you have to throw your body off a
building?" - They Might Be Giants, http://www.tmbg.com
----
Word of the week: Serendipity, see http://www.bartleby.com/61/93/S0279300.html
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]