Re: Not operator in regular expression

From: Date: Fri, 28 Jul 2000 14:11:32 +0000
Subject: Re: Not operator in regular expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8771@lists.php.net to get a copy of this message
David, The NOT operator for regexes if ^, and the regex to do what you want is: echo ereg_replace("[^a-zA-Z_]","",$t); - Kev David Newcomb wrote: > Hi all, > > Help! > > I have a variable > > $t="this IS h_ard 12 ! etc"; > > and I want to return > > $t="thisISh_ardetc"; > > I would like to remove all characters which are not [a-zA-Z_] > > Is there a regular expression operator for NOT so I don't > have to list all the alternatives? > > Some thing like: > > echo ereg_replace("~[a-zA-Z_]","_",$t); > > Regards, > David.

« previous php.general (#8771) next »