Page 1 of 1

PHP: Wie kann ich eine preg_grep-Suche invertieren?

Posted: 2003-08-04 15:41
by c14l
Hallo!

Also, was ich machen möchte sieht in Perl so aus:

Code: Select all

@neu = grep(!/^something$/,@alt);
@neu erhält also alle Werte aus @alt, die _nicht_ auf die RegEx /^something$/ zutreffen. Wie bekomme ich das in PHP hin? Ich hab schon folgendes (glücklos) versucht:

Code: Select all

$neu = preg_grep(!"/^something$/",$alt);
$neu = preg_grep("!/^something$/",$alt);
...und http://de3.php.net/manual/en/function.preg-grep.php ist dazu auch nicht grade informativ. Wo muß ich das "!" setzen? Danke schon mal für die Hilfe!

Re: PHP: Wie kann ich eine preg_grep-Suche invertieren?

Posted: 2003-08-04 22:20
by c14l
Ok, schon gefunden:

Code: Select all

$bla = preg_grep ("/^something$/", $bla, PREG_GREP_INVERT); 

Gruß
C14L