The main export is a function that takes a string an options object.
not(string[, options]);
Example
var not =require('regex-not');console.log(not('foo'));//=> /^(?:(?!^(?:foo)$).)+$/
Strict matching
By default, the returned regex is for strictly (not) matching the exact given pattern (in other words, "match this string if it does NOT exactly equalfoo"):
var re =not('foo');console.log(re.test('foo')); //=> falseconsole.log(re.test('bar')); //=> trueconsole.log(re.test('foobar')); //=> trueconsole.log(re.test('barfoo')); //=> true
.create
Returns a string to allow you to create your own regex:
You can relax strict matching by setting options.contains to true (in other words, "match this string if it does NOT containfoo"):
var re =not('foo');console.log(re.test('foo', {contains:true})); //=> falseconsole.log(re.test('bar', {contains:true})); //=> trueconsole.log(re.test('foobar', {contains:true})); //=> falseconsole.log(re.test('barfoo', {contains:true})); //=> false
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
Running 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:
$ npm install && npm test
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command: