RE: [PHP] PREG_REPLACE, with array error...

From: Date: Mon, 30 Oct 2000 22:45:20 +0000
Subject: RE: [PHP] PREG_REPLACE, with array error...
Groups: php.general 
Request: Send a blank email to php-general+get-22754@lists.php.net to get a copy of this message
how would it be? somthing like: "/e/W"? > -----Original Message----- > From: Lars Torben Wilson [mailto:torben@pinc.com] > Sent: Monday, October 30, 2000 7:36 PM > To: Roy Nasser > Cc: Php (E-mail) > Subject: Re: [PHP] PREG_REPLACE, with array error... > > > Roy Nasser writes: > > Any ideas why the following code doesnt work? I get > "Warning: Delimiter must > > not be alphanumeric or backslash in > /home/httpd/html/pre2000/answer.php on > > line 168", this is the line with the first preg_replace > statement.... > > > > <? > > $q = " ".$q; > > $remove = array ( > > "o", > > "quando", > > "porque", > > "do", > > [snip] > > > "é", > > "e", > > "a", > > "de", > > "vez" > > ); > > > > $q = preg_replace($remove,"",$q); > > $q = ereg_replace(" ","",$q); > > echo $q; > > > > ?> > > You've forgotten the PCRE delimiters around the expressions; they > should be something like this: > > "/é/", > "/e/", > "/a/", > "/de/", > > Just a small warning, though--the above will remove, for instance, all > instances of the letters o, e, etc from the $q string, even if they > occur inside a word or something like that. This may be what you want, > but if not, you should use \w or \W or something (I forget which) to > ensure that only whole words are matched. > > > Good luck, > > Torben > > -- > +----------------------------------------------------------------+ > |Torben Wilson <torben@php.net> Netmill iTech| > |http://www.coastnet.com/~torben > http://www.netmill.fi| > |Ph: 1 250 383-9735 torben@netmill.fi| > +----------------------------------------------------------------+ >

« previous php.general (#22754) next »