Browse the jar content to search resources that match the pattern.

@param jarOrZipFile the jar to explore
@param searchPattern the regex pattern used as a filter

@return list of resources that match the pattern
507580
@SuppressWarnings("unchecked")
    private static List<String> getResourcesFromJarOrZipFile(final File jarOrZipFile, final Pattern searchPattern) {
        final List<String> resources = new ArrayList<>();

        try (ZipFile zf = new ZipFile(jarOrZipFile);) {

            final Enumeration<ZipEntry> e = (Enumeration<ZipEntry>) zf.entries();
            while (e.hasMoreElements()) {
                final ZipEntry ze = e.nextElement();
                checkResource(resources, searchPattern, ze.getName());
            }

        } catch (final IOException e) {
            LOGGER.log(FILE_UNREADABLE, e);
        }
        return resources;
    }
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;
    }
24799
public static Pattern parseFilter( final String spec )
    {
        StringBuffer sb = new StringBuffer();
        for( int j = 0; j < spec.length(); j++ )
        {
            char c = spec.charAt( j );
            switch( c )
            {
                case '.':
                    sb.append( "\\." );
                    break;

                case '*':
                    // test for ** (all directories)
                    if( j < spec.length() - 1 && spec.charAt( j + 1 ) == '*' )
                    {
                        sb.append( ".*" );
                        j++;
                    }
                    else
                    {
                        sb.append( "[^/]*" );
                    }
                    break;
                default:
                    sb.append( c );
                    break;
            }
        }
        String s = sb.toString();
        try
        {
            return Pattern.compile( s );
        }
        catch( Exception e )
        {
            throw new IllegalArgumentException( "Invalid character used in the filter name", e );
        }
    }
1368126
public static Matcher<String> containsPatterns(String... patterns) {
        List<Matcher<? super String>> matchers = new ArrayList<Matcher<? super String>>();
        for (String pattern : patterns) {
            matchers.add(pattern(pattern));
        }
        return allOf(matchers);
    }
1209947
static List<String> parsePattern(String pattern) {
    List<String> parameters = new ArrayList<>(4);
    Matcher matcher = PARAM_REGEX.matcher(pattern);
    while (matcher.find()) {
      parameters.add(matcher.group(1));
    }
    return parameters;
  }
190460
public final List<T> searchSorted(String searchString, String sort) {
        return this.findSortedByQuery(FULLTEXT_QUERY, sort, searchString);
    }
846545
public static List<String> expand(String filePattern) throws IOException {
    List<String> fullyExpanded = new ArrayList<String>();
    List<StringWithOffset> toExpand = new ArrayList<StringWithOffset>();
    toExpand.add(new StringWithOffset(filePattern, 0));
    while (!toExpand.isEmpty()) {
      StringWithOffset path = toExpand.remove(0);
      List<StringWithOffset> expanded = expandLeftmost(path);
      if (expanded == null) {
        fullyExpanded.add(path.string);
      } else {
        toExpand.addAll(0, expanded);
      }
    }
    return fullyExpanded;
  }
114632
public static <T extends Tree> Matcher<T> packageMatches(Pattern pattern) {
    return (tree, state) -> pattern.matcher(getPackageFullName(state)).matches();
  }
84727
public static List<File> listFileWithRegexFileName(final File rootDir, final String regexFileNamePattern) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir)
				.filter(new RegexFileNameFilter(regexFileNamePattern)).toList();
	}
717221
public Stream<HString> findAllPatterns(@NonNull String regex) {
      return findAllPatterns(Pattern.compile(regex));
   }
571468
public Map<String, ConfigurationMetadataProperty> find(final boolean strict, final Pattern propertyPattern) {
        val results = new HashMap<String, ConfigurationMetadataProperty>();

        val repository = new CasConfigurationMetadataRepository();
        val props = repository.getRepository().getAllProperties();

        props.forEach((k, v) -> {
            val matched = StreamSupport.stream(RelaxedPropertyNames.forCamelCase(k).spliterator(), false)
                .map(Object::toString)
                .anyMatch(name -> strict
                    ? RegexUtils.matches(propertyPattern, name)
                    : RegexUtils.find(propertyPattern, name));
            if (matched) {
                results.put(k, v);
            }
        });

        return results;
    }
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
891906
protected org.apache.log4j.helpers.PatternParser createPatternParser(final String pattern) {
		return new FoundationLoggingPatternParser(pattern);
	}
310907
protected List<Object> filterAttributeValuesByPattern(final Set<Object> attributeValues, final Pattern pattern) {
        return attributeValues.stream().filter(v -> RegexUtils.matches(pattern, v.toString(), completeMatch)).collect(Collectors.toList());
    }
357877
static String [] searchArchiveForClasses( URL url ) throws IOException {
        List<String> list = new ArrayList<>();
        ZipInputStream zip = new ZipInputStream(url.openStream());

        ZipEntry ze;
        while( zip.available() == 1 )
            if ( (ze = zip.getNextEntry()) != null
                    && isClassFileName( ze.getName() ) )
                list.add( canonicalizeClassName( ze.getName() ) );
        zip.close();

        return list.toArray( new String[list.size()] );
    }
183300
public static List<File> listFileWithWildcardFileName(final File rootDir, final String fileNamePattern) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir).filter(new WildcardFileNameFilter(fileNamePattern))
				.toList();
	}
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());
	}