Re: Function to strip returns
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
.
Relevant Pages
- RE: [PHP] preg_match problem
... Because you're using forward slashes /.../ to delimit your pattern, regexp is using the / in your character class to terminate your pattern: ... Even if you had a character there that it could accept as a pattern modifier, the character class would be incomplete so the pattern is doomed to fail. ... PHP is reducing this to a single backslash before the space character. ... I think you intend this to be two backslashes in the pattern so you need four backslashes in PHP: ... (php.general) - Re: Regular Expression to match the domain part of an email address
... Tame it by naming that pattern. ... write separate tests. ... class Roska {public static void main{ ... I'm not sure if the escape is needed for `-' in a character class, ... (comp.lang.java.programmer) - Re: preg_match function for URLs
... ..oO(Phil Latio) ... There's another error in your pattern: ... The first part creates a character class, ... use another delimiter and maybe the /i modifier: ... (comp.lang.php) - Re: How to delete non-ASCII chars in file
... On Fri, Sep 5, 2008 at 10:58 AM, Giorgos Keramidas ... pattern with `' where `xxxx' is the character class; ... A character class may not be used as an endpoint of a range. ... There are two special cases\(dd of bracket expressions: ... (freebsd-questions) - Re: Function to strip returns
... Use a quantifier to match series of newlines/tabs. ... Use a character class to match different combinations of characters. ... but using a greedy quantifier instead of alternative is not a good idea. ... Windows clients are 90%+ of all accessing web pages. ... (comp.lang.php) |
|