# wild2wild_matcher

> Compare two wildcard strings to each other

Latest version **0.5.4** (published 2020-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install wild2wild_matcher
pnpm add wild2wild_matcher
yarn add wild2wild_matcher
bun add wild2wild_matcher
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.4 |
| Published | 2020-08-04 |
| First published | 2020-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Elad Project |
| Maintainers | eladp |
| Keywords | wildcard, matcher |

## Links

- npm: https://www.npmjs.com/package/wild2wild_matcher
- Repository: https://github.com/EladProject/wild2wild_matcher
- Homepage: https://github.com/EladProject/wild2wild_matcher#readme
- Issues: https://github.com/EladProject/wild2wild_matcher/issues
- npm.io page: https://npm.io/package/wild2wild_matcher

## Recent versions

- 0.5.4 (latest) — 2020-08-04
- 0.5.3 — 2020-07-30
- 0.5.2 — 2020-07-30
- 0.5.1 — 2020-07-30
- 0.5.0 — 2020-07-30

## README

# wild2wild_matcher

A function to match two wildcard strings to each other.<br>
Supported wild cards:<br>
\* - Zero or more characters<br>
? - Exactly one character<br><br>

This is actually a subset of a regular expression partial match. Both of which are not available OOB in JS.<br>

### A use case example:
When only part of the input is available and there is a need to understand whether this input may potentially be completed
to match a desired pattern (described with wildcards) in order to show a notification to the user.<br>
Appending the partial input with * and matching it with the desired pattern will reveal if the input can be completed to match
the pattern.<br>

### Examples:



    const {w2match} = require('wild2wild_matcher');

    console.log(w2match('hello\*world', 'hello\*'));           // => true
    console.log(w2match('hello\*world', 'hello\*jimbo'));      // => false
    console.log(w2match('h?llo?wor?d', '??llo w?rld'));        // => true
    console.log(w2match('he??o?world', 'he\*d'));              // => true
    console.log(w2match('he??o?world', 'helo world\*'));       // => false

### Efficiency
This recursive algorithm is not the most efficient one. A more efficient (but less elegant) algorithm can be written by separating to several cases.
For example, noticing that if there is at least one * in the middle of each string, there is only a need to compare the 
prefixes (before the first *s) and the suffixes (after the last *s). 
Another case is when only one string has *s in the middle. Then there is a need to check each substring delimited by *s for containment in the other string and also check 
the order.
Other cases include when the *s are in the beginning and end of the strings.

---
_Source: https://npm.io/package/wild2wild_matcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
