original_string: public static function increment_shortname($shortname) {
          global $DB;
          do {
              $matches = array();
              if (!preg_match('/(.*?)([0-9]+)$/', $shortname, $matches)) {
                  $newshortname = $shortname . '_2';
              } else {
                  $newshortname = $matches[1] . ($matches[2]+1);
              }
              $shortname = $newshortname;
          } while ($DB->record_exists('course', array('shortname' => $shortname)));
          return $shortname;
      }
code: public static function increment_shortname($shortname) {
          global $DB;
          do {
              $matches = array();
              if (!preg_match('/(.*?)([0-9]+)$/', $shortname, $matches)) {
                  $newshortname = $shortname . '_2';
              } else {
                  $newshortname = $matches[1] . ($matches[2]+1);
              }
              $shortname = $newshortname;
          } while ($DB->record_exists('course', array('shortname' => $shortname)));
          return $shortname;
      }
code_tokens: public static function increment_shortname ( $ shortname ) { global $ DB ; do { $ matches = array ( ) ; if ( ! preg_match ( '/(.*?)([0-9]+)$/' , $ shortname , $ matches ) ) { $ newshortname = $ shortname . '_2' ; } else { $ newshortname = $ matches [ 1 ] . ( $ matches [ 2 ] + 1 ) ; } $ shortname = $ newshortname ; } while ( $ DB -> record_exists ( 'course' , array ( 'shortname' => $ shortname ) ) ) ; return $ shortname ; }
docstring: Helper to increment a shortname.
  
  This considers that the shortname passed has to be incremented.
  
  @param string $shortname shortname to increment.
  @return string new shortname.
docstring_tokens: Helper to increment a shortname .