patternToSearch = $patternToSearch; $this->patternToSearchQuoted = self::getPatternQuoted($patternToSearch); $this->columnToFilter = $columnToFilter; $this->filter(); } static public function getPatternQuoted( $pattern ) { return '/'. str_replace('/', '\/', $pattern) .'/'; } /* * Performs case insensitive match */ static public function match($pattern, $patternQuoted, $string) { return @preg_match($patternQuoted . "i", $string) == 1; } protected function filter() { foreach($this->table->getRows() as $key => $row) { //instead search must handle // - negative search with -piwik // - exact match with "" // see (?!pattern) A subexpression that performs a negative lookahead search, which matches the search string at any point where a string not matching pattern begins. if( !self::match($this->patternToSearch, $this->patternToSearchQuoted, $row->getColumn($this->columnToFilter))) { $this->table->deleteRow($key); } } } }