make new RegExp object to match file names that fit the pattern <name>[.env].ext
@param  {String}           name        base name of the file
@return {RegExp}                       RegExp generated from base name and extensions
8854
function makeFilenameRegex(name) {
  if (!_.isString(name)) {
    throw new TypeError('name parameter must be of type "String"');
  }

  const regexString = `^${name}(?:[.](.+))?.(${fileExtensions.join('|')})$`;
  return new RegExp(regexString);
}
580259
function cloneRegexp(re) {
  const pattern = re.source;

  let flags = '';

  if (re.global) flags += 'g';
  if (re.multiline) flags += 'm';
  if (re.ignoreCase) flags += 'i';
  if (re.sticky) flags += 'y';
  if (re.unicode) flags += 'u';

  return new RegExp(pattern, flags);
}
910510
function basename(p, ext){
  utils.assertString(p, 'path');
  return path.basename(p.val, ext && ext.val);
}
970499
function match(regexp) {
        var O = requireObjectCoercible(this);
        var matcher = regexp == undefined ? undefined : regexp[MATCH];
        return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
      }
1128117
function match(regexp) {
      var O = defined(this);
      var fn = regexp == undefined ? undefined : regexp[MATCH];
      return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
    }
61094
function patternFor(self, basename) {
  if (!has(self.__patterns__, basename)) {
    var pattern;

    var extname = path.extname(basename);

    if (has(self.__aliases__, extname) && self.__aliases__[extname].length) {
      basename = path.basename(basename, extname);
      pattern  = escapeRegexp(basename) +
        '(?:' + [ extname ].concat(self.__aliases__[extname]).map(escapeRegexp).join('|') + ')';
    } else {
      pattern  = escapeRegexp(basename);
    }

    pattern += '(?:' + self.__extensions__.map(escapeRegexp).join('|') + ')*';
    self.__patterns__[basename] = new RegExp('^' + pattern + '$');
  }

  return self.__patterns__[basename];
}
983841
function parseName(name) {
  if (name) {
    const arr = name.split('.')
    const len = arr.length

    if (len > 2) {
      return arr.slice(0, -1).join('.')
    }
    else if (len === 2 || len === 1) {
      return arr[0]
    }
  }
  return name
}
719169
function (name_pattern, spec_pattern) {
            /*  step 1: match mandatory name  */
            if (typeof name_pattern === "string") {
                if (this.name() !== name_pattern)
                    return false;
            }
            else if (   typeof name_pattern === "object"
                     && name_pattern instanceof RegExp) {
                if (!(this.name().match(name_pattern)))
                    return false;
            }
            else
                throw _cs.exception("matches", "invalid name pattern");

            /*  step 2: match optional specification  */
            var spec = this.__spec;
            for (var key in spec_pattern) {
                if (!_cs.isown(spec_pattern, key))
                    continue;
                if (!_cs.isdefined(spec[key]))
                    return false;
                var value = spec_pattern[key];
                switch (typeof spec[key]) {
                    case "number":
                    case "boolean":
                        if (spec[key] !== value)
                            return false;
                        break;
                    case "string":
                        if (!(   (   typeof value === "string"
                                  && spec[key] === value)
                              || (   typeof value === "object"
                                  && value instanceof RegExp
                                  && !(spec[key].match(value)))))
                            return false;
                        break;
                }
            }
            return true;
        }
340382
function splitPrefix(name) {
        var prefix,
          index = name ? name.indexOf("!") : -1;
        if (index > -1) {
          prefix = name.substring(0, index);
          name = name.substring(index + 1, name.length);
        }
        return [prefix, name];
      }
51984
function get_assets(name, extension = 'js')
	{
		let chunk = json.assetsByChunkName[name]

		// a chunk could be a string or an array, so make sure it is an array
		if (!(Array.isArray(chunk)))
		{
			chunk = [chunk]
		}

		return chunk
			// filter by extension
			.filter(name => path.extname(extract_path(name)) === `.${extension}`)
			// adjust the real path (can be http, filesystem)
			.map(name => options.assets_base_url + name)
	}
1257067
function getExtensionlessFilename( filename ) {
	return filename.substr( 0, filename.length - path.extname( filename ).length);
}
787968
def name=(name)
      if name.nil?
        fail ArgumentError, "name cannot be nil"
      end

      if name !~ Regexp.new(/^(?!(.*[\\\"\\*\\\\\\>\\<\\?\/\\:\\|]+.*)|(.*[\\.]?.*[\\.]+$)|(.*[ ]+$))/)
        fail ArgumentError, "invalid value for 'name', must conform to the pattern /^(?!(.*[\\\"\\*\\\\\\>\\<\\?\/\\:\\|]+.*)|(.*[\\.]?.*[\\.]+$)|(.*[ ]+$))/."
      end

      @name = name
    end
686122
function extname(ext) {
  var str = ext.charAt(0) === '.' ? ext.slice(1) : ext;
  if (str === 'yml') str = 'yaml';
  return str;
}
780518
private function findFile($name, $ext)
	{
		if (null === $ext)
			$ext = $this->default_ext;
		$basename = basename($name);
		$type = $this->getTypeForExt($ext);

		if (isset(self::$files[$this->prefix][$type][$name])
		 && file_exists($file = self::$files[$this->prefix][$type][$name]))
			return $file;

		foreach ($this->paths as $path)
		{
			$prefixes = isset($path['prefixes']) ? $path['prefixes'] : array();
			$prefix = isset($prefixes[$type]) ? $prefixes[$type] . '/' : '';

			foreach ($path['directories'] as $directory)
			{
				$files = glob(rtrim($directory, '/') . '/' . $prefix . $name . '.*');
				if (!$files) // no file found
					continue;

				foreach ($files as $file)
				{
					list($found_name, $found_ext) = $this->getNameAndExtension($file);
					
					if ($basename != basename($found_name) || $ext != $found_ext)
						continue;

					self::$files[$this->prefix][$ext][$name] = $file;
					self::$file_added = true;

					return self::$files[$this->prefix][$ext][$name];
				}
			}
		}

		return null;
	}
840170
def pattern_for(basename)
        extname = File.extname(basename)
        aliases = @reverse_aliases[extname]

        if aliases
          basename = File.basename(basename, extname)
          aliases  = [extname] + aliases
          aliases_pattern = aliases.map { |e| Regexp.escape(e) }.join("|")
          basename_re = Regexp.escape(basename) + "(?:#{aliases_pattern})"
        else
          basename_re = Regexp.escape(basename)
        end

        extension_pattern = extensions.map { |e| Regexp.escape(e) }.join("|")
        /^#{basename_re}(?:#{extension_pattern})*$/
      end
1210212
function (srcPath, options) {
        _.defaults(options || (options = {}), DEFAULT_OPTIONS);
        var separator = options.separator;
        var extname = path.extname(srcPath);
        var reg = new RegExp('^.+' + separator + '(.+)((' + separator + '.+)|(@\\d+x))\\' + extname + '$');
        if (extname === '.styl' || extname === '.css') {
            reg = new RegExp('^.+' + separator + '(.+)\\' + extname + '$');
        }
        var result = path.basename(srcPath).match(reg);
        return result && result[1];
    }
339577
def ext_from_filename(filename):
    
    try:
        base, ext = filename.lower().rsplit(".", 1)
    except ValueError:
        return ''
    ext = ".{0}".format(ext)
    all_exts = [x.extension for x in chain(magic_header_array,
                                           magic_footer_array)]

    if base[-4:].startswith("."):
        # For double extensions like like .tar.gz
        long_ext = base[-4:] + ext
        if long_ext in all_exts:
            return long_ext
    return ext