source: trip-planner-front/node_modules/glob-to-regexp/README.md@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.2 KB
Line 
1# Glob To Regular Expression
2
3[![Build Status](https://travis-ci.org/fitzgen/glob-to-regexp.png?branch=master)](https://travis-ci.org/fitzgen/glob-to-regexp)
4
5Turn a \*-wildcard style glob (`"*.min.js"`) into a regular expression
6(`/^.*\.min\.js$/`)!
7
8To match bash-like globs, eg. `?` for any single-character match, `[a-z]` for
9character ranges, and `{*.html, *.js}` for multiple alternatives, call with
10`{ extended: true }`.
11
12To obey [globstars `**`](https://github.com/isaacs/node-glob#glob-primer) rules set option `{globstar: true}`.
13NOTE: This changes the behavior of `*` when `globstar` is `true` as shown below:
14When `{globstar: true}`: `/foo/**` will match any string that starts with `/foo/`
15like `/foo/index.htm`, `/foo/bar/baz.txt`, etc. Also, `/foo/**/*.txt` will match
16any string that starts with `/foo/` and ends with `.txt` like `/foo/bar.txt`,
17`/foo/bar/baz.txt`, etc.
18Whereas `/foo/*` (single `*`, not a globstar) will match strings that start with
19`/foo/` like `/foo/index.htm`, `/foo/baz.txt` but will not match strings that
20contain a `/` to the right like `/foo/bar/baz.txt`, `/foo/bar/baz/qux.dat`, etc.
21
22Set flags on the resulting `RegExp` object by adding the `flags` property to the option object, eg `{ flags: "i" }` for ignoring case.
23
24## Install
25
26 npm install glob-to-regexp
27
28## Usage
29```js
30var globToRegExp = require('glob-to-regexp');
31var re = globToRegExp("p*uck");
32re.test("pot luck"); // true
33re.test("pluck"); // true
34re.test("puck"); // true
35
36re = globToRegExp("*.min.js");
37re.test("http://example.com/jquery.min.js"); // true
38re.test("http://example.com/jquery.min.js.map"); // false
39
40re = globToRegExp("*/www/*.js");
41re.test("http://example.com/www/app.js"); // true
42re.test("http://example.com/www/lib/factory-proxy-model-observer.js"); // true
43
44// Extended globs
45re = globToRegExp("*/www/{*.js,*.html}", { extended: true });
46re.test("http://example.com/www/app.js"); // true
47re.test("http://example.com/www/index.html"); // true
48```
49
50## License
51
52Copyright (c) 2013, Nick Fitzgerald
53
54All rights reserved.
55
56Redistribution and use in source and binary forms, with or without modification,
57are permitted provided that the following conditions are met:
58
59* Redistributions of source code must retain the above copyright notice, this
60 list of conditions and the following disclaimer.
61
62* Redistributions in binary form must reproduce the above copyright notice, this
63 list of conditions and the following disclaimer in the documentation and/or
64 other materials provided with the distribution.
65
66THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
67ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
68WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
69DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
70ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
71(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
72LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
73ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
75SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Note: See TracBrowser for help on using the repository browser.