Retrieve all resources that match the search pattern from the java.class.path.

@param searchPattern the pattern used to filter all matching files

@return Sorted list of resources that match the pattern
508565
public static Collection<String> getClasspathResources(final Pattern searchPattern) {

        final List<String> resources = new ArrayList<>();

        final ClassLoader cl = Thread.currentThread().getContextClassLoader();

        if (hasJavaWebstartLibrary() && cl instanceof JNLPClassLoaderIf) {

            LOGGER.log(USE_JNLP_CLASSLOADER);

            final JNLPClassLoaderIf wsLoader = (JNLPClassLoaderIf) cl;

            // System.out.println("URLs "+ wsLoader.getURLs());
            for (final JARDesc jd : wsLoader.getLaunchDesc().getResources().getLocalJarDescs()) {
                try {

                    final JarFile jarFile = wsLoader.getJarFile(jd.getLocation());

                    LOGGER.log(PARSE_CACHED_JAR_FILE, jarFile.getName(), jd.getLocationString());

                    resources.addAll(getResources(jarFile.getName(), searchPattern, true));
                } catch (final IOException e) {
                    LOGGER.log(CANT_READ_CACHED_JAR_FILE, jd.getLocation());
                }
            }

        } else {

            LOGGER.log(USE_DEFAULT_CLASSLOADER);

            final String[] classpathEntries = CLASSPATH.split(CLASSPATH_SEPARATOR);
            for (final String urlEntry : classpathEntries) {
                // Parse the classpath entry and apply the given pattern as filter
                resources.addAll(getResources(urlEntry, searchPattern, false));
            }
        }

        // Sort resources
        Collections.sort(resources);

        return resources;
    }
1369491
public static boolean matches(Collection<PathPattern> patterns, List<String> path) {
		for (PathPattern pattern : patterns)
			if (pattern.matches(path))
				return true;
		return false;
	}
1058727
protected Pattern[] queryDetectionPattern(final Pattern... pattern) {
        if (pattern == null) {
            throw new IllegalArgumentException();
        } // end of if

        // ---

        if (this.queryDetection == null) {
            return pattern;
        } // end of if

        // ---

        final Pattern[] patterns = 
            new Pattern[this.queryDetection.length + pattern.length];

        System.arraycopy(this.queryDetection, 0, 
                         patterns, 0, 
                         this.queryDetection.length);

        int i = this.queryDetection.length;

        for (final Pattern p : pattern) {
            patterns[i++] = p;
        } // end of for

        return patterns;
    }
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());
	}
56629
@Programmatic
    public List<ApplicationTenancy> findByNameOrPathMatchingCached(final String search) {
        return queryResultsCache.execute(new Callable<List<ApplicationTenancy>>() {
            @Override public List<ApplicationTenancy> call() throws Exception {
                return findByNameOrPathMatching(search);
            }
        }, ApplicationTenancyRepository.class, "findByNameOrPathMatchingCached", search);
    }
886502
public void importBeans(String resourcePattern) {
        try {
            Resource[] resources = resourcePatternResolver.getResources(resourcePattern);
            for (Resource resource : resources) {
                importBeans(resource);
            }
        } catch (IOException e) {
            LOG.error("Error loading beans for resource pattern: " + resourcePattern, e);
        }
    }
917711
public function findByPattern($rulePattern) {
        $logger = $GLOBALS['logger'];
        $path    = 'rules/';
        $request = $this->_remoteServer->get($path);
        $query = $request->getQuery();
        $query->set('pattern',$rulePattern);
        $logger->info(print_r($query,1));
        //$request = $this->_remoteServer->get($path, array(), array('pattern'=>urlencode($rulePattern))); 
        try {
            $response = $request->send();
            if ($response->getStatusCode() !== 200) {
                throw new \Exception('Unable to handle request');
            }
            $rawResponse = $response->getBody('true');
            return $rawResponse;
        } catch (\Exception $e) {
            throw $e; 
        }
        
    }
406506
public void findPatterns() 
        throws Exception {
        HashSet<String> patterns = new HashSet<String>();
        for (String phrase : filtered_phrases) {
            String phrase_arr[] = phrase.split(":");
            String A = phrase_arr[0];
            String B = phrase_arr[1];
            //System.err.println(A + ": " + B);

            patterns.addAll(searchDirectoryForPattern(new File(DATA_DIR), A, B));
        }
        Iterator iter = patterns.iterator();
        while (iter.hasNext()) {
            String curr_pattern_str = (String)iter.next();
            String[] curr_pattern = curr_pattern_str.split("\\s");
            int curr_length = curr_pattern.length;
            //System.err.println("length of pattern: " + curr_length);
            //do a for loop with all combinatorials of wildcard patterns
            //for each iteration do a wildcard search
            for (int comb = 0; comb < (int)Math.pow(2.0,(double)curr_length); comb++) {
                String comb_pattern = "\\s" + combinatorialPatternMaker(curr_pattern, curr_length, comb);
                try {
                    int score = countWildcardPhraseFrequencies(new File(DATA_DIR), ".*" + comb_pattern + ".*");
                    InterveningWordsPattern db_pattern = new InterveningWordsPattern(comb_pattern);
                    db_pattern.setOccurrences(score);
                    pattern_list.put(db_pattern, score); //insert the pattern into database (only if it has a high enough score)

                    //System.err.println(comb_pattern + ": " + score);
                } catch (Exception e) {
                    System.err.println("could not perform wildcard search");
                }
            }
        }
    }
182833
def search_file(pattern, file_path):
    
    try:
        with open(file_path) as file:
            string = file.read()
    except PermissionError:
        return []

    matches = re.findall(pattern, string)

    return matches
1053718
public static List<String> getAllGroups(Pattern pattern, CharSequence content) {
		return getAllGroups(pattern, content, true);
	}
972713
public static boolean match(WildcardPattern[] patterns, String value) {
    for (WildcardPattern pattern : patterns) {
      if (pattern.match(value)) {
        return true;
      }
    }
    return false;
  }
1093606
public List<IstioResource> deployIstioResourcesFromClasspathPattern(String pattern) {

        final List<IstioResource> istioResources = new ArrayList<>();
        final FastClasspathScanner fastClasspathScanner = new FastClasspathScanner();

        fastClasspathScanner.matchFilenamePattern(pattern, (FileMatchProcessor) (relativePath, inputStream, lengthBytes) -> {
            istioResources.addAll(deployIstioResources(inputStream));
            inputStream.close();
        }).scan();

        return istioResources;
    }
989590
public static List<Match> searchPlain(Collection<? extends BioPAXElement> eles, Pattern pattern)
	{
		List<Match> list = new LinkedList<Match>();

		Map<BioPAXElement, List<Match>> map = search(eles, pattern);
		for (List<Match> matches : map.values())
		{
			list.addAll(matches);
		}
		return list;
	}
200450
public static boolean matchPath(String path, String pattern) {
		List<String> pathElements = PATH_SPLITTER.splitToList(path);
		List<String> patternElements = PATH_SPLITTER.splitToList(pattern);
		return matchTokens(pathElements.toArray(new String[0]), patternElements.toArray(new String[0]));
	}
1329272
public static Predicate<String> ant(final String antPattern) {
    return new Predicate<String>() {
      @Override
      public boolean test(String input) {
        AntPathMatcher matcher = new AntPathMatcher();
        return matcher.match(antPattern, input);
      }
    };
  }
684365
private function matchPatterns($pathName, $patternList)
    {
        foreach ($patternList as $pattern) {
            if ($this->matchPattern($pathName, $pattern)) {
                return $pattern;
            }
        }

        return false;
    }
1118342
public static PathMatcher getPathMatcher(
      String syntaxAndPattern, String separators, ImmutableSet<PathNormalization> normalizations) {
    int syntaxSeparator = syntaxAndPattern.indexOf(':');
    checkArgument(
        syntaxSeparator > 0, "Must be of the form 'syntax:pattern': %s", syntaxAndPattern);

    String syntax = Ascii.toLowerCase(syntaxAndPattern.substring(0, syntaxSeparator));
    String pattern = syntaxAndPattern.substring(syntaxSeparator + 1);

    switch (syntax) {
      case "glob":
        pattern = GlobToRegex.toRegex(pattern, separators);
        // fall through
      case "regex":
        return fromRegex(pattern, normalizations);
      default:
        throw new UnsupportedOperationException("Invalid syntax: " + syntaxAndPattern);
    }
  }