View Full Version : New Line Input Parsing
Trashed20
29-09-2002, 13:24
Well, as everyone knows, not everyone knows how to use the <br> tag when posting on a website, and that is my problem. I want to have my input be automatically parsed when you hit enter
to get a new line like this. I've been looking round the web and haven't found any info on how to do this. if anyone has any insite you help would be gratly appriciated.
p.s. Brandon, why do you have the spell checker commented out in the source for pages? does it not work?
Where are you trying to do this? In a form? In an WYSIWYG editor? Either way, new lines are normally denoted by a '\n' character, if that helps any.
Trashed20
29-09-2002, 16:22
im talking about text box input through html forms, like the ones used to post these messages. For example you hit enter 3 times you would get spaces in the text, but i need to convert that to \n or <br> tags
Well, if the script parsing the HTML form is written in PHP, you can simply use the nl2br() function. Lets say the textbox input is saved to the variable $info. To convert all the newline characters present in it, you would do:
$info = nl2br($info);Otherwise, you could do some sort of regex command. Post some more information if the script isn't written in PHP.
Brandon Martus
29-09-2002, 20:30
Joel suggested the correct PHP function.
To do it in PERL, you could do this:
$someText =~ s/\n\n/<p>/g;
$someText =~ s/\n/<br>/g;
And, to answer your question about the spell checker.
vBulletin has it commented out by default, because I believe the service they were using started to charge people.
They just leave the code there in case you want to pay for the service, I think.
Trashed20
29-09-2002, 22:08
thanks, i prolly should have said that i was using php.
Vbulletin make you pay for everything now doens't it. how much is a liscence up to now?
Brandon Martus
30-09-2002, 10:46
vBulletin doesn't make you pay for the spell checker, the spell checker service makes you pay for it.
vBulletin is $35/yr, which really isn't that bad for such a powerful piece of software that is continually updated, and fully customizable.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.