Re: still not friends with RegExps..

From: Date: Wed, 23 May 2001 06:58:41 +0000
Subject: Re: still not friends with RegExps..
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-53996@lists.php.net to get a copy of this message
Previously, Zef Hemel said: > $string = preg_replace("/[\\\*\+\-;]/s","",$string); > > I think, you might have to escape the ; too You don't need to escape * or + inside a character class since they don't have a special meaning inside a character class. You will need to use '\\\\' to match a backslash, however. And if you move the hypen to the last position in the character class, it loses its magic property as a range specifier and no longer needs to be quoted either. This should do what you want: $string = preg_replace("/[\\\\;*+-]/s", "", $string); -dan -- The process for understanding customers primarily involves sitting around with other marketing people and talking about what you would to if you were dumb enough to be a customer. -Scott Adams, "The Dilbert Principle"

« previous php.general (#53996) next »