{"library":"regex-not","title":"Negative Regular Expression Generator","description":"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.","language":"javascript","status":"maintenance","last_verified":"Tue Apr 21","install":{"commands":["npm install regex-not"],"cli":null},"imports":["const not = require('regex-not');","const not = require('regex-not');\nconst regexString = not.create('foo');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const not = require('regex-not');\n\n// Default behavior: matches if the string does NOT exactly equal 'foo'\nconst reStrict = not('foo');\nconsole.log('Strict matching:');\nconsole.log(`'foo' should be false: ${reStrict.test('foo')}`);     // Expected: false\nconsole.log(`'bar' should be true: ${reStrict.test('bar')}`);     // Expected: true\nconsole.log(`'foobar' should be true: ${reStrict.test('foobar')}`); // Expected: true (not exact)\n\n// Option: matches if the string does NOT contain 'foo'\nconst reContains = not('foo', { contains: true });\nconsole.log('\\nContains matching:');\nconsole.log(`'foo' should be false: ${reContains.test('foo')}`);     // Expected: false\nconsole.log(`'bar' should be true: ${reContains.test('bar')}`);     // Expected: true\nconsole.log(`'foobar' should be false: ${reContains.test('foobar')}`); // Expected: false (contains 'foo')\n\n// Get just the regex pattern string\nconst patternString = not.create('bar');\nconsole.log(`\\nGenerated pattern string for 'bar': ${patternString}`);\nconst customRegExp = new RegExp(patternString);\nconsole.log(`Using custom RegExp: '${customRegExp.source}'.test('bar') should be false: ${customRegExp.test('bar')}`);","lang":"javascript","description":"Demonstrates strict (default) and 'contains' negation using the `not` function, and how to get the raw regex pattern string using `not.create`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}