PHPExiftool\Driver\Metadata\MetadataBag::filterKeysByRegExp PHP Method

filterKeysByRegExp() public method

Returns all the elements which key matches the regexp
public filterKeysByRegExp ( string $regexp ) : MetadataBag
$regexp string
return MetadataBag
    public function filterKeysByRegExp($regexp)
    {
        $partitions = $this->partition(function ($key, $element) use($regexp) {
            return preg_match($regexp, $key);
        });
        return array_shift($partitions);
    }

Usage Example

 /**
  * @covers PHPExiftool\Driver\Metadata\MetadataBag::filterKeysByRegExp
  */
 public function testFilterKeysByRegExp()
 {
     $this->object->set('oneKey', 'oneValue');
     $this->object->set('oneSecondKey', 'anotherValue');
     $this->object->set('thirdKey', 'thirdValue');
     $this->assertEquals(2, count($this->object->filterKeysByRegExp('/one.*/')));
 }