All Projects → jonschlinkert → regex-not

jonschlinkert / regex-not

Licence: MIT license
Create a javascript regular expression for matching everything except for the given string.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to regex-not

Js Regular Expression Awesome
📄我收藏的正则表达式大全,欢迎补充
Stars: ✭ 120 (+287.1%)
Mutual labels:  regex, regular-expression
learn-regex
Learn regex the easy way
Stars: ✭ 43,660 (+140738.71%)
Mutual labels:  regex, regular-expression
Micromatch
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Stars: ✭ 1,979 (+6283.87%)
Mutual labels:  regex, regular-expression
FileRenamerDiff
A File Renamer App featuring a difference display before and after the change.
Stars: ✭ 32 (+3.23%)
Mutual labels:  regex, regular-expression
compiler-design-lab
These are my programs for compiler design lab work in my sixth semester
Stars: ✭ 47 (+51.61%)
Mutual labels:  regex, regular-expression
To Regex Range
Pass two numbers, get a regex-compatible source string for matching ranges. Fast compiler, optimized regex, and validated against more than 2.78 million test assertions. Useful for creating regular expressions to validate numbers, ranges, years, etc.
Stars: ✭ 97 (+212.9%)
Mutual labels:  regex, regular-expression
Grex
A command-line tool and library for generating regular expressions from user-provided test cases
Stars: ✭ 4,847 (+15535.48%)
Mutual labels:  regex, regular-expression
Regexr
For composing regular expressions without the need for double-escaping inside strings.
Stars: ✭ 53 (+70.97%)
Mutual labels:  regex, regular-expression
Regex For Regular Folk
🔍💪 Regular Expressions for Regular Folk — A visual, example-based introduction to RegEx [BETA]
Stars: ✭ 242 (+680.65%)
Mutual labels:  regex, regular-expression
Regexpu
A source code transpiler that enables the use of ES2015 Unicode regular expressions in ES5.
Stars: ✭ 201 (+548.39%)
Mutual labels:  regex, regular-expression
Globbing
Introduction to "globbing" or glob matching, a programming concept that allows "filepath expansion" and matching using wildcards.
Stars: ✭ 86 (+177.42%)
Mutual labels:  regex, regular-expression
regex-comuns
Um estudo de regex comuns
Stars: ✭ 15 (-51.61%)
Mutual labels:  regex, regular-expression
Hyperscan Java
Match tens of thousands of regular expressions within milliseconds - Java bindings for Intel's hyperscan 5
Stars: ✭ 66 (+112.9%)
Mutual labels:  regex, regular-expression
Orchestra
One language to be RegExp's Successor. Visually readable and rich, technically safe and extended, naturally scalable, advanced, and optimized
Stars: ✭ 103 (+232.26%)
Mutual labels:  regex, regular-expression
Emoji Regex
A regular expression to match all Emoji-only symbols as per the Unicode Standard.
Stars: ✭ 1,134 (+3558.06%)
Mutual labels:  regex, regular-expression
Regex Dos
👮 👊 RegEx Denial of Service (ReDos) Scanner
Stars: ✭ 143 (+361.29%)
Mutual labels:  regex, regular-expression
Regex
A sane interface for php's built in preg_* functions
Stars: ✭ 909 (+2832.26%)
Mutual labels:  regex, regular-expression
Rexrex
🦖 Composable JavaScript regular expressions
Stars: ✭ 34 (+9.68%)
Mutual labels:  regex, regular-expression
Regex.persian.language
Collection of Regex for validating, filtering, sanitizing and finding Persian strings
Stars: ✭ 172 (+454.84%)
Mutual labels:  regex, regular-expression
Regaxor
A regular expression fuzzer.
Stars: ✭ 35 (+12.9%)
Mutual labels:  regex, regular-expression

regex-not NPM version NPM monthly downloads NPM total downloads Linux Build Status

Create a javascript regular expression for matching everything except for the given string.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

Install

Install with npm:

$ npm install --save regex-not

Usage

var not = require('regex-not');

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 equal foo"):

var re = not('foo');
console.log(re.test('foo'));     //=> false
console.log(re.test('bar'));     //=> true
console.log(re.test('foobar'));  //=> true
console.log(re.test('barfoo'));  //=> true

.create

Returns a string to allow you to create your own regex:

console.log(not.create('foo'));
//=> '(?:(?!^(?:foo)$).)+'

Options

options.contains

You can relax strict matching by setting options.contains to true (in other words, "match this string if it does NOT contain foo"):

var re = not('foo');
console.log(re.test('foo', {contains: true}));     //=> false
console.log(re.test('bar', {contains: true}));     //=> true
console.log(re.test('foobar', {contains: true}));  //=> false
console.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:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

You might also be interested in these projects:

  • regex-cache: Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of… more | homepage
  • to-regex: Generate a regex from a string or array of strings. | homepage

Contributors

Commits Contributor
9 jonschlinkert
1 doowb
1 EdwardBetts

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on February 19, 2018.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].