Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

fixing what textareas do to input

by skazat (Hermit)
on Jun 05, 2000 at 05:23 UTC ( #16352=perlquestion: print w/replies, xml ) Need Help??
skazat has asked for the wisdom of the Perl Monks concerning the following question:

heya,
i'm having a bit of trouble trying to get input from text areas to format pretty much the same way as they are written out in the first place in the textarea on the webpage form. it seems sometimes extra lines are put into everyline break from them, etc, and this seems to be a platform problem... ie, macintoshes (like mine) might add a hard return followed by a newline while windows will add two newlines, i know there is one regex that can take care of it, (i've seen it here, honest) i was wondering if anyone's memory was a bit better than mine

thanks

Replies are listed 'Best First'.
Re: fixing what textareas do to input
by Zoogie (Curate) on Jun 05, 2000 at 08:42 UTC
    Perhaps: $data =~ s/(\r\n|\n\r|\r)/\n/g This converts CR's, LF's, and any combination of the two into a single newline (I hope... haven't tested it).
      If you output the textarea input in HTML you might consider changing the right hand side of Zoogies regexp to /<br>\n/g
      -- bash$ :(){ :|:&};:
      Would $data =~ s/(\r|\n){1,2})/\n/g work as well? (Unfortunately, I don't have time to test it out-- and I'm notorious for FUing my regexes the first time out.)

      The Autonomic Pilot

Re: fixing what textareas do to input
by httptech (Chaplain) on Jun 05, 2000 at 18:55 UTC
    In addition to using the s/\r\n/\n/g style expression to even out the linefeeds, you may want to set the textarea to WRAP="NONE" to force the user to do their own linefeeds. If you let the browser do the wrapping you may get inconsistent results.
      Except of course that that leads to annoyed users :)
        heh that's how the textareas work on Perl Monks (at least in my browser)... I don't find it annoying in the least. I rather like being able to choose where my lines break. I find it annoying when the browser wants to choose for me.
Re: fixing what textareas do to input
by skazat (Hermit) on Jun 05, 2000 at 23:56 UTC
    awesome,
    thats exactly the one i was looking for,
    kudos for everyone
    chocolate chip ones.
    hmmm.

    -justin simoni
    !skazat!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://16352]
Approved by root
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2018-07-19 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (411 votes). Check out past polls.

    Notices?