Re: regex for multiple line breakes
| From: | Fernando Castillo Aparicio | Date: | Wed, 14 Oct 2009 10:26:40 +0000 |
| Subject: | Re: regex for multiple line breakes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298890@lists.php.net to get a copy of this message | ||
You are replacing 1 or more matchs of a new line. To match 2 or more you can use "{2,}".
It's a range, first number means min matches, second max matches. Omitting last number means no
max limit.
$data[txt] = preg_replace('
[\r\n]{2,}',"\n",$data[txt]);
________________________________
De: Merlin Morgenstern <merlin_x@fastmail.fm>
Para: php-general@lists.php.net
Enviado: mié,14 octubre, 2009 12:17
Asunto: [PHP] regex for multiple line breakes
Hi there,
I am trying to remove multiple linebreakes from a textarea input. Spammers tend to insert multiple
line breakes. The problem is, that I want to allow 2 line breaks so basic formating should be
allowed.
I am doing this by regex:
$data[txt] = preg_replace('[\r\n]+',"\n",$data[txt]);
I would need a regex that allows \r\n\r\n, but not more than this.
Thank you for any help,
Merlin
-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php