https://github.com/andrewdacenko/format-matcher
https://github.com/andrewdacenko/format-matcher
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/andrewdacenko/format-matcher
- Owner: andrewdacenko
- License: mit
- Created: 2016-09-01T22:10:36.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-02T18:57:17.000Z (almost 10 years ago)
- Last Synced: 2025-10-04T05:48:33.053Z (9 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Format matcher
Find best format for input string using prepared formats.
[](https://travis-ci.org/andrewdacenko/format-matcher)
## Usage
Install
```
npm i format-matcher -S
```
Require and use
```javascript
const makeMatcher = require('format-matcher');
const formats = ['A 9', 'A-9', '9 A'];
const find = makeMatcher(formats);
const input = 'H-1';
const format = find(input);
format === 'A-9'; // true
```
### String pattern for input and format
Any combination of characters are allowed for input and format,
but any non `A-z` & `0-9` & `-` or space would be removed.
Thus for these formats would be treated as same:
* `A-9 A.` - dot would be removed
* `A 8*-L` - asterisk would be removed
* `Q-1 M=` - equals would be removed
Same applies for inputs