[ back to toc ]

Stripping Carriage Returns

Date: 2002/03/26 08:55

Q:
Hello,
I'm using BigNose Bird's BNB form located at:
http://www.bignosebird.com/carchive/bnbform.shtml

In the form I'm accepting a textarea and need to replace line breaks in
the field with <br> tags for the .bout database output.

I was wondering if you now of a way to accomplish this task using the BNB
Form?

Thank for the help!
A:
At some point the content of the text are gets into a variable. I do not
know the source of the Perl script that performs this BNBFORM by heart,
but I am sure that as some point you will have the content of the text
area in a variable. Let's call this variable '$textarea'. In this case all
you need is an expression:

$textarea =~ s/\n/\&lf\;BR\>\;\n/g;

this will replace all new-line characters to the desirec HTML line break
(and a new line to have the text a bit look readable).

Regards,
Peter

[ back to toc ]