Re: Function to strip returns
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Function to strip returns

From: Ewoud Dronkert <firstname@lastname.net.invalid>
Date: Mon Oct 31 2005 - 09:41:59 CET

JackM wrote:
> $value = preg_replace("(\r\n|\n|\r|\t)", "", $value);

That is not a pattern, it needs pattern delimiters at the start and end.
You don't need the parentheses because there's nothing outside them. Use a
quantifier to match series of newlines/tabs. Use a character class to
match different combinations of characters. I always use single quotes
around patterns to minimize the use of backslashes.

  $value = preg_replace('/[\r\n\t]+/', '', $value);

-- 
E. Dronkert
Received on Mon Nov 21 02:53:23 2005