Re: carriage return
| From: | Jochem Maas | Date: | Fri, 05 Aug 2005 10:13:28 +0000 |
| Subject: | Re: carriage return | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220054@lists.php.net to get a copy of this message | ||
Diana Castillo wrote:
How can I with php detect when there is a carriage return at the end of the text field in a mysql table?get the data out of the DB first. stick it in $myString $myString = "wtf I fond a carriage return - horsedrawn even.\n"; if (preg_match("#[\n|\r|\r\n]$#", $myString)) { echo "wtf I fond a carriage return - horsedrawn even."; } tip: using trim() on $myString will strip a trailing CR. tip: want to allow blank spaces after the CR, use this regexp instead. "#[\n|\r|\r\n][ ]*$#" e.g: $myString = "wtf I fond a carriage return - horsedrawn even.\r\n "; if (preg_match("#[\n|\r|\r\n][ ]*$#", $myString)) { echo "wtf I fond a carriage return - horsedrawn even."; } now can I have your roomkey? :-P also if you want to know what \n and \r and \r\n are about then you might start by searching for posts by Marco Tabini 3 days back on this list