|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Recognizing Line breaks in a textarea-field?
Hi,
after a while of searching here i didn't found an answer: I do have a field like this: <textarea name=message rows=25 cols=50></textarea> If anyone enters data with line breaks like: bla bla bla it will be sent without them like: bla bla bla What do i need to do if i want to get it sent like entered? Thanks for hints! |
|
#2
|
|||
|
|||
|
Hi ,
When you press enter "/n" will be concatenated. so, when you print the value search for "/n" and replace it with "<br>". Hope this solves your problem... |
|
#3
|
||||
|
||||
|
It's actually "\n", and this is platform dependent. Unix machines send "\n" and windows machines send "\r\n".
Try www.perlmonks.org, I think there are example regexes there. |
|
#4
|
|||
|
|||
|
oh sorry ..i mistakenly typed "\n" as "/n"...
|
|
#5
|
|||
|
|||
|
Thanks ... than this should work:
$message =~s/(\r\n|\n\r|\r)/<BR>\n/g; but it didn't ... why? |
|
#6
|
||||
|
||||
|
You've done a regex for \r and not \n. If you're on a UNIX platform you'll want \n. No platform, to my knowledge, uses \r alone. So you want to do this instead:
$message =~s/(\r\n|\n\r|\n)/<BR>\n/g; |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Recognizing Line breaks in a textarea-field? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|