original_string: public function addFilter(string $expression): CopyDictionaryJob
      {
          // Check if the first and last char match - if not, we must encapsulate with '/'.
          if ($expression[0] !== substr($expression, -1)) {
              $expression = '/' . $expression . '/';
          }
  
          // Test if the regex is valid.
          try {
              preg_match($expression, '');
          } catch (\Throwable $error) {
              throw new \InvalidArgumentException(
                  sprintf('Filter "%s" is not a valid regular expression - Error: %s', $expression, $error->getMessage()),
                  0,
                  $error
              );
          }
  
          $this->filters[] = $expression;
  
          return $this;
      }
code: public function addFilter(string $expression): CopyDictionaryJob
      {
          // Check if the first and last char match - if not, we must encapsulate with '/'.
          if ($expression[0] !== substr($expression, -1)) {
              $expression = '/' . $expression . '/';
          }
  
          // Test if the regex is valid.
          try {
              preg_match($expression, '');
          } catch (\Throwable $error) {
              throw new \InvalidArgumentException(
                  sprintf('Filter "%s" is not a valid regular expression - Error: %s', $expression, $error->getMessage()),
                  0,
                  $error
              );
          }
  
          $this->filters[] = $expression;
  
          return $this;
      }
code_tokens: public function addFilter ( string $ expression ) : CopyDictionaryJob { // Check if the first and last char match - if not, we must encapsulate with '/'. if ( $ expression [ 0 ] !== substr ( $ expression , - 1 ) ) { $ expression = '/' . $ expression . '/' ; } // Test if the regex is valid. try { preg_match ( $ expression , '' ) ; } catch ( \ Throwable $ error ) { throw new \ InvalidArgumentException ( sprintf ( 'Filter "%s" is not a valid regular expression - Error: %s' , $ expression , $ error -> getMessage ( ) ) , 0 , $ error ) ; } $ this -> filters [ ] = $ expression ; return $ this ; }
docstring: Add a regular expression.
  
  @param string $expression The regular expression matching keys to filter away.
  
  @return CopyDictionaryJob
  
  @throws \InvalidArgumentException When the regex is invalid.
docstring_tokens: Add a regular expression .