# Wildcard

Matching strings to wildcards pattern is useful and often needed. Using regular expression may help, but is not a top performance solution. `Wildcard` class matches strings to wildcard patterns using `*` and `?` characters, and that does very fast and good!

### Matching strings

Here are some examples:

```java
Wildcard.match("CfgOptions.class", "*C*g*cl*");         // true   
Wildcard.match("CfgOptions.class", "*g*c**s");          // true!   
Wildcard.match("CfgOptions.class", "??gOpti*c?ass");    // true   
Wildcard.match("CfgOpti*class", "*gOpti\\*class");      // true   
Wildcard.match("CfgOptions.class", "C*ti*c?a?*");       // true
```

### Matching file paths

`Wildcard` class supports path matching wildcards. It matches path against pattern using `*`, `?` and `**` wildcards. Both path and the pattern are tokenized on path separators (`\` and `/`). `**` represents deep tree wildcard, as in Ant.

```java
Wildcard.matchPath("/foo/soo/doo/boo", "/**/bo*");          // true
Wildcard.matchPath("/foo/one/two/three/boo", "**/t?o/**");  // true
```

### Wildcards in Jodd

Wildcard matching is used in many places in *Jodd*. As the general rule-of-the-thumb, everywhere where file paths are involved in scanning and matching, the `matchPath()` method is used, otherwise, the classic `path()`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://util.jodd.org/utilitites/wildcard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
