@types/regex-not

  • Version 1.0.2
  • Published
  • 5.69 kB
  • No dependencies
  • MIT license

Install

npm i @types/regex-not
yarn add @types/regex-not
pnpm add @types/regex-not

Overview

TypeScript definitions for regex-not

Index

Functions

function create

create: (str: string, options?: Options) => string;
  • Returns

    A string to allow you to create your own regex.

    Example 1

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

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

function regexNot

regexNot: typeof regexNot;
  • Create a javascript regular expression for matching everything except for the given string.

    ### 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").

    Example 1

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

    console.log(not('foo')); //=> /^(?:(?!^(?: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

Interfaces

interface Options

interface Options {}

    property contains

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

      false

      Example 1

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

      const re = not('foo', {contains: true}); console.log(re.test('foo')); //=> false console.log(re.test('bar')); //=> true console.log(re.test('foobar')); //=> false console.log(re.test('barfoo')); //=> false

    property endChar

    endChar?: string;
    • Controls the outermost repetition modifier in the generated RegExp.

      '+'

      Example 1

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

      const re = not('foo'); // => '^(?:(?!^(?:foo)$).)+$' const re = not('foo', {endChar: '*'}); // => '^(?:(?!^(?:foo)$).)*$'

    property safe

    safe?: boolean;
    • Throw an error when a potentially catastrophic exponential-time regular expression is detected. See [strict-regex](https://github.com/davisjam/safe-regex) for more details and potential implications.

      false

    property strictClose

    strictClose?: boolean;
    • Controls whether the end of input anchor ($) should be generated for the pattern.

      true

      Example 1

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

      const re = not('foo'); // => '^(?:(?!^(?:foo)$).)+$' const re = not('foo', {strictClose: '*'}); // => '^(?:(?!^(?:foo)$).)+'

    property strictOpen

    strictOpen?: boolean;
    • Controls whether the start of input anchor (^) should be generated for the pattern.

      true

      Example 1

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

      const re = not('foo'); // => '^(?:(?!^(?:foo)$).)+$' const re = not('foo', {strictOpen: '*'}); // => '(?:(?!^(?:foo)$).)+$'

    Package Files (1)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (0)

    No dev dependencies.

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/regex-not.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/regex-not)
    • HTML
      <a href="https://www.jsdocs.io/package/@types/regex-not"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>