<p>
Looks for file names which match the regex in the directory.
</p>
<p>
Example:<br>
BoofMiscOps.findMatches(new File("/path/to/directory"), ".+jpg");
</p>

@param directory directory
@param regex file name regex
@return array of matching files
962629
public static File[] findMatches( File directory , String regex ) {
		final Pattern p = Pattern.compile(regex); // careful: could also throw an exception!
		return directory.listFiles(file -> p.matcher(file.getName()).matches());
	}
835946
def matching_files(self):
        
        matching = []
        matcher = self.file_path_regex
        pieces = self.file_path_regex.pattern.split(sep)
        partial_matchers = list(map(re.compile, (
            sep.join(pieces[:i + 1]) for i in range(len(pieces)))))

        for root, dirs, files in walk(self.top_dir, topdown=True):
            for i in reversed(range(len(dirs))):
                dirname = relpath(join(root, dirs[i]), self.top_dir)
                dirlevel = dirname.count(sep)
                if not partial_matchers[dirlevel].match(dirname):
                    del dirs[i]

            for filename in files:
                if matcher.match(filename):
                    matching.append(abspath(join(root, filename)))

        return matching
698862
public static void deleteFilesByRegex(File dir, String regex) {
        if(regex == null) {
            throw new DataUtilException("Filename regex can not be null");
        }
        FilenameFilter filter = new RegexFilenameFilter(regex);
        FileDeleter.deleteFiles(dir, filter);
    }
830680
@Override
	public boolean cd(String directory) {
		if (StrUtil.isBlank(directory)) {
			// 当前目录
			return true;
		}
		try {
			channel.cd(directory.replaceAll("\\\\", "/"));
			return true;
		} catch (SftpException e) {
			return false;
		}
	}
633300
public static List<File> findFilesWithFilter(final File dir, final String... extension)
	{
		final List<File> foundedFileList = new ArrayList<>();
		final File[] children = dir.listFiles(new MultiplyExtensionsFileFilter(true, extension));
		for (final File element : children)
		{
			// if the entry is a directory
			if (element.isDirectory())
			{ // then
				// find recursively in the directory and put it in a List.
				// Put the founded files in the main List.
				foundedFileList.addAll(findFilesWithFilter(element, extension));
			}
			else
			{
				foundedFileList.add(element.getAbsoluteFile());
			}
		}
		return foundedFileList;
	}
826394
protected function findFilesAsSplFileInfo(string $regex, string $path) {
		
		$objects = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator($path), 
			RecursiveIteratorIterator::SELF_FIRST
		);
		
		$filter = new RegexIterator($objects, $regex);
		$map = [];
		
		foreach ($filter as $entry) {
			$map[] = $entry;
		}
		
		return count($map) > 0 ? $map : [];
	}
926461
public List<String> findList(String str, String regex) {
		ArrayList<String> ret = new ArrayList<String>();
		if (str == null || regex == null)
			return ret;
		Matcher m = Pattern.compile(regex).matcher(str);
		while (m.find()) {
			ret.add(m.group());
		}
		return ret;
	}
504334
def find_macthing_files(match):
    """"""
    last_slash = match.rfind('/')
    if last_slash == -1:
        dirname = '.'
        match_prefix = match
        result_prefix = ''
    else:
        dirname = match[0:last_slash]
        match_prefix = match[last_slash + 1:]
        result_prefix = dirname + '/'
    return [result_prefix + filename for filename in os.listdir(dirname) if filename.startswith(match_prefix)]
183300
public static List<File> listFileWithWildcardFileName(final File rootDir, final String fileNamePattern) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir).filter(new WildcardFileNameFilter(fileNamePattern))
				.toList();
	}
600114
function readDir (dir, regex = /^(?:)$/) {
  return new Promise((resolve, reject) =>
    fs.readdir(dir, (err, files) => err
      ? reject(err)
      : resolve(Promise.all(files.map(checkFileName.bind(null, dir, regex))))))
    .then(values =>
      [].concat(...values)
        .filter(i => i))
}
221835
public static List<File> listFilesRecursively(File dir) {
		List<File> fileList = newArrayList();
		addFilesRecursively(dir, fileList);
		return fileList;
	}
1128746
def find_directories(root, pattern):
    
    results = []
    for base, dirs, files in os.walk(root):
        matched = fnmatch.filter(dirs, pattern)
        results.extend(os.path.join(base, d) for d in matched)
    return results
296305
public Stream<HString> findAllPatterns(@NonNull TokenRegex regex) {
      return Streams.asStream(new Iterator<HString>() {
         TokenMatcher m = regex.matcher(HString.this);
         HString nextMatch = null;

         private boolean advance() {
            if (nextMatch == null && m.find()) {
               nextMatch = m.group();
            }
            return nextMatch != null;
         }

         @Override
         public boolean hasNext() {
            return advance();
         }

         @Override
         public HString next() {
            if (!advance()) {
               throw new NoSuchElementException();
            }
            HString toReturn = nextMatch;
            nextMatch = null;
            return toReturn;
         }
      });
   }
201515
public String[] matchFileNamesWithPattern(File[] files,
			String fileNameRegExp) throws SshException {
		// set up variables for regexp matching
		Pattern mpattern = null;
		PatternCompiler aPCompiler = new Perl5Compiler();
		PatternMatcher aPerl5Matcher = new Perl5Matcher();
		// Attempt to compile the pattern. If the pattern is not valid,
		// throw exception
		try {
			mpattern = aPCompiler.compile(fileNameRegExp);
		} catch (MalformedPatternException e) {
			throw new SshException("Invalid regular expression:"
					+ e.getMessage(), SshException.BAD_API_USAGE);
		}

		Vector<String> matchedNames = new Vector<String>();

		for (int i = 0; i < files.length; i++) {
			if ((!files[i].getName().equals("."))
					&& (!files[i].getName().equals(".."))
					&& (!files[i].isDirectory())) {
				if (aPerl5Matcher.matches(files[i].getName(), mpattern)) {
					// call get for each match, passing true, so that it doesnt
					// repeat the search
					matchedNames.addElement(files[i].getName());
				}
			}
		}

		// return (String[]) matchedNames.toArray(new String[0]);
		String[] matchedNamesStrings = new String[matchedNames.size()];
		matchedNames.copyInto(matchedNamesStrings);
		return matchedNamesStrings;
	}
1225672
def find(cls, searched_dir, pattern):
        
        Log.debug('find {0} with pattern: {1}'.format(searched_dir, pattern))
        matched_files = []
        for root_dir, dir_names, file_names in os.walk(searched_dir,
                                                       followlinks=False):
            for file_name in file_names:
                if fnmatch.fnmatch(file_name, pattern):
                    file_path = os.path.join(root_dir, file_name)
                    if not os.path.islink(file_path):
                        matched_files.append(file_path)
        matched_files.sort()
        return matched_files
357924
public static final Set<File> findFileByDirAndSubBySuffix(File dir,String ...suffix)
	{
		return findFileByDirAndSub(dir,new FileFilter() {
			@Override
			public boolean accept(File pathname) 
				{
					if(pathname.isDirectory())
					{
						return true;
					}
					if(pathname.isFile())
					{
						for(String s:suffix)
						{
							if(pathname.getName().endsWith(s))
							{
								return true;
							}
						}
					}
					return false;
				}
			});
	}
847198
public static final File[] findJarFileByDir(File dir)
	{
		if(dir==null)
		{
			throw new NullArgumentException("dir ==null");
		}
		if(dir.isFile())
		{
			throw new IllegalArgumentException("dir "+dir+" is not a dir");
		}
		if(!dir.exists())
		{
			throw new IllegalArgumentException("dir "+dir+" not found");
		}
		File[] jarFiles = dir.listFiles(new FileFilter() {
			@Override
			public boolean accept(File pathname) 
				{
					return pathname.getName().endsWith(".jar");
				}
			});
		return jarFiles;
	}