JWildcard
A collection of wildcard utilities. This library helps to convert wildcards to regex string. Wildcards can be declared using custom made rules.
Getting Started
Gradle build.gradle
repositories {
jcenter()
}
dependencies {
compile 'com.yevdo:jwildcard:1.4'
}
Maven pom.xml
<dependency>
<groupId>com.yevdo</groupId>
<artifactId>jwildcard</artifactId>
<version>1.4</version>
<type>pom</type>
</dependency>
API
API documentation https://alenon.github.io/JWildcard/
Examples:
This wildcard:
"mywil?card*"
will be converted to this regex string:
"\Qmywil\E.\Qcard\E.*"
If you wish to convert wildcard to regex string use:
JWildcard.wildcardToRegex("mywil?card*");
Default wildcard rules are: "?" -> ".", "*" -> ".*", but you can change the default behaviour if you wish to, by simply defining the new rules.
JWildcard.wildcardToRegex(wildcard, rules, strict);
If you wish to check matching directly you can use this:
JWildcard.matches("mywild*", "mywildcard");
If wish to convert wildcard string to SQL like pattern:
JWildcard.wildcardToSqlPattern("?wild*Ca?rd*") // outputs this => _wild%Ca_rd%