Wildcard matching in Java

前端 未结 6 1924
渐次进展
渐次进展 2020-12-14 23:13

I\'m writing a simple debugging program that takes as input simple strings that can contain stars to indicate a wildcard match-any

*.wav  // matches 

        
6条回答
  •  猫巷女王i
    2020-12-14 23:36

    There is small utility method in Apache Commons-IO library: org.apache.commons.io.FilenameUtils#wildcardMatch(), which you can use without intricacies of the regular expression.

    API documentation could be found in: https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/FilenameUtils.html#wildcardMatch(java.lang.String,%20java.lang.String)

提交回复
热议问题