original_string: public static function add_attributes($tag, $attributes) {
          $tag = self::remove_attributes($tag, array_keys($attributes));
          if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
              return $tag;
          }
          $rv = $matches[1];
          foreach ($attributes as $name => $value) {
              $rv .= " $name=\"".s($value).'"';
          }
          $rv .= $matches[2];
          return $rv;
      }
code: public static function add_attributes($tag, $attributes) {
          $tag = self::remove_attributes($tag, array_keys($attributes));
          if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
              return $tag;
          }
          $rv = $matches[1];
          foreach ($attributes as $name => $value) {
              $rv .= " $name=\"".s($value).'"';
          }
          $rv .= $matches[2];
          return $rv;
      }
code_tokens: public static function add_attributes ( $ tag , $ attributes ) { $ tag = self :: remove_attributes ( $ tag , array_keys ( $ attributes ) ) ; if ( ! preg_match ( '/^(<.*?)(>.*)$/s' , $ tag , $ matches ) ) { return $ tag ; } $ rv = $ matches [ 1 ] ; foreach ( $ attributes as $ name => $ value ) { $ rv .= " $name=\"" . s ( $ value ) . '"' ; } $ rv .= $ matches [ 2 ] ; return $ rv ; }
docstring: Adds attributes to the media tags
  
  @param string $tag html tag which properties are extracted, for example "<video ...>....</video>"
  @param array $attributes key-value pairs of attributes to be added
  @return string
docstring_tokens: Adds attributes to the media tags