RE: [PHP] regex and newline

From: Date: Fri, 02 May 2003 06:11:39 +0000
Subject: RE: [PHP] regex and newline
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146063@lists.php.net to get a copy of this message
I found out that the enter key didn't give me \n but \r\n instead so it works now. -----Original Message----- From: Michael [mailto:zooming@gamebox.net] Sent: May 2, 2003 12:12 AM To: 'Php-General@Lists.Php.Net' Subject: RE: [PHP] regex and newline Hi John Let me make it more clear. I did a sample of what I want done below. If I type in the box "[list]" and then press the enter key to get the "\n". Then if I press the submit button I want "[list]\n" to turn to "[changed]". I don't know how to search for newlines in input boxes. Hopes that's more clear. test.php ======== <html> <head> <title></title> </head> <body> <form method="post" action="test.php" > <textarea name="text" rows="5" cols="25"> <?php if ( isset($_POST['text']) ) { $text = str_replace("[list]\n", "[changed]", $_POST['text']); echo $text; } ?> </textarea><br> <input type="submit" type="button"> </form> </body> </html> -----Original Message----- From: John W. Holmes [mailto:holmes072000@charter.net] Sent: May 1, 2003 11:46 PM To: 'Michael'; 'Php-General@Lists.Php.Net' Subject: RE: [PHP] regex and newline > $text = "[list]\n"; > $text = preg_replace("/\[list\]\n?/i","<ul>", $text); > > What I want $text to look like is this afterwards: > $text="<ul>" Umm... str_replace("[list]\n",'<ul>',$text); ?? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03 --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03 --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03

« previous php.general (#146063) next »