regex-not, currently at version 1.0.2, is a utility package designed to simplify the creation of JavaScript regular expressions that match everything *except* a given string. It abstracts away the complexity of crafting negative lookahead assertions, which can be challenging and error-prone to write manually. The library is primarily a CommonJS module, targeted at Node.js environments from version 0.10.0 and above. Its release cadence is infrequent, suggesting a mature, stable API that is in a maintenance phase rather than active feature development. A key differentiator is its dual functionality: it can generate regexes for strict negation (the string does *not* exactly match) or 'contains' negation (the string does *not* contain the substring), providing flexibility for various inverse matching requirements.
npm install regex-notVerified import paths — ran on the pinned version, not inferred.
Demonstrates strict (default) and 'contains' negation using the `not` function, and how to get the raw regex pattern string using `not.create`.
Use `const not = require('regex-not');` in CJS files. For ESM, you might need to use `import not from 'regex-not';` but be aware that it relies on Node.js's CJS-ESM interoperability or a bundler's transpilation.For substring negation, call `not(string, { contains: true })`. For example, `not('foo', { contains: true })` will return a regex that doesn't match 'foobar'.Evaluate if the current functionality meets your needs without expecting future feature enhancements or major refactorings to adopt newer JS standards like native ESM.
If your project is ESM-first, try `import not from 'regex-not';` (though this package is CJS-primary, Node.js often handles this for default exports). Alternatively, convert your file to CommonJS if possible, or configure a bundler (like Webpack or Rollup) to handle CJS modules in an ESM project.
If you want the regex to match strings that *do not contain* a specific substring, you need to use the `contains` option: `not('your_pattern', { contains: true })`.No dependency data recorded yet.