source: trip-planner-front/node_modules/regex-not/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: 4.4 KB
Line 
1# regex-not [![NPM version](https://img.shields.io/npm/v/regex-not.svg?style=flat)](https://www.npmjs.com/package/regex-not) [![NPM monthly downloads](https://img.shields.io/npm/dm/regex-not.svg?style=flat)](https://npmjs.org/package/regex-not) [![NPM total downloads](https://img.shields.io/npm/dt/regex-not.svg?style=flat)](https://npmjs.org/package/regex-not) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/regex-not.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/regex-not)
2
3> Create a javascript regular expression for matching everything except for the given string.
4
5Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
6
7## Install
8
9Install with [npm](https://www.npmjs.com/):
10
11```sh
12$ npm install --save regex-not
13```
14
15## Usage
16
17```js
18var not = require('regex-not');
19```
20
21The main export is a function that takes a string an options object.
22
23```js
24not(string[, options]);
25```
26
27**Example**
28
29```js
30var not = require('regex-not');
31console.log(not('foo'));
32//=> /^(?:(?!^(?:foo)$).)+$/
33```
34
35**Strict matching**
36
37By default, the returned regex is for strictly (not) matching the exact given pattern (in other words, "match this string if it does NOT _exactly equal_ `foo`"):
38
39```js
40var re = not('foo');
41console.log(re.test('foo')); //=> false
42console.log(re.test('bar')); //=> true
43console.log(re.test('foobar')); //=> true
44console.log(re.test('barfoo')); //=> true
45```
46
47### .create
48
49Returns a string to allow you to create your own regex:
50
51```js
52console.log(not.create('foo'));
53//=> '(?:(?!^(?:foo)$).)+'
54```
55
56### Options
57
58**options.contains**
59
60You can relax strict matching by setting `options.contains` to true (in other words, "match this string if it does NOT _contain_ `foo`"):
61
62```js
63var re = not('foo');
64console.log(re.test('foo', {contains: true})); //=> false
65console.log(re.test('bar', {contains: true})); //=> true
66console.log(re.test('foobar', {contains: true})); //=> false
67console.log(re.test('barfoo', {contains: true})); //=> false
68```
69
70## About
71
72<details>
73<summary><strong>Contributing</strong></summary>
74
75Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
76
77</details>
78
79<details>
80<summary><strong>Running Tests</strong></summary>
81
82Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
83
84```sh
85$ npm install && npm test
86```
87
88</details>
89
90<details>
91<summary><strong>Building docs</strong></summary>
92
93_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
94
95To generate the readme, run the following command:
96
97```sh
98$ npm install -g verbose/verb#dev verb-generate-readme && verb
99```
100
101</details>
102
103### Related projects
104
105You might also be interested in these projects:
106
107* [regex-cache](https://www.npmjs.com/package/regex-cache): Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of… [more](https://github.com/jonschlinkert/regex-cache) | [homepage](https://github.com/jonschlinkert/regex-cache "Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in surprising performance improvements.")
108* [to-regex](https://www.npmjs.com/package/to-regex): Generate a regex from a string or array of strings. | [homepage](https://github.com/jonschlinkert/to-regex "Generate a regex from a string or array of strings.")
109
110### Contributors
111
112| **Commits** | **Contributor** |
113| --- | --- |
114| 9 | [jonschlinkert](https://github.com/jonschlinkert) |
115| 1 | [doowb](https://github.com/doowb) |
116| 1 | [EdwardBetts](https://github.com/EdwardBetts) |
117
118### Author
119
120**Jon Schlinkert**
121
122* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
123* [github/jonschlinkert](https://github.com/jonschlinkert)
124* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
125
126### License
127
128Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
129Released under the [MIT License](LICENSE).
130
131***
132
133_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 19, 2018._
Note: See TracBrowser for help on using the repository browser.