This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

enregex
TypeScript icon, indicating that this package has built-in type declarations

1.8.3 • Public • Published

enregex

Installation

npm install enregex | npm i enregex

Usages

// ES5
const Enregex = require("enregex")
// ES6
import Enregex from "enregex"
// Or import both 'Enregex' and 'Util'.
const { Enregex, Util } = require("enregex")
import { Enregex, Util } from "enregex"

// Creating an instance of Enregex by many ways:
// - using string:
new Enregex("foo", "igm")
// - using regex:
new Enregex(/bar/yu)
// - using array:
new Enregex(["hello", "world"])

Enregex functions

Enregex.build()

Builds an Enregex instance with more human-friendly syntax.

Enregex.build("startsWith: 0 or abc or (def \\(ghi\\)); endsWith: 1 or ( smth ); src: (?:not-before(a)b or c not-after(d)) or group<abc>(abc)repeat: (<abc>, 2)", "abuuuismgadfge")
// Enregex /^(?:0|abc|def \(ghi\))(?:(?<!a)b|c(?!d))|(abc)abc{2}(?:1| smth )$/gimsu

<Enregex>.prototype.array

Returns an array of strings (Array<string>) which can be matched by the regex.

new Enregex(/foo(bar)?|bar?/).array
// (4) ["foo", "foobar", "ba", "bar"]

<Enregex>.prototype.includes()

Returns a boolean whether the given argument includes the regex or not.

new Enregex(/foo(bar)?|bar?/).includes(["ba", "foobar"])
// true

new Enregex(/foo(bar)?|bar?/).includes(["bar", "fooba"])
// false

<Enregex>.prototype.split()

Returns an array of regex (Array<Enregex>) by the 'alternate' character.

new Enregex(/foo|bar/i).split()
// (2) [/foo/i, /bar/i]

Util.beacons()

Finds beacons and their content into an array.

Util.beacons("-anchor There is a -tag rain-bow - \\-here. -a -b", { position: "start" })
// (2) [ [ '-anchor', ' There is a' ], [ '-tag', ' rain-bow - \\-here.' ] ]

Util.checkURLs()

Returns URLs by given parameters.

Util.checkURLs({ secured: !0, str: "There is a link [https://code.visualstudio.com/api/references/theme-color#peek-view-colors](https://code.visualstudio.com/api/references/theme-color#peek-view-colors)." })
// (1) ['https://code.visualstudio.com/api/references/theme-color#peek-view-colors']

Util.endsWith()

Returns a boolean whether true or false if a string or a line ends with the wanted string with the wanted options or not.

Util.endsWith("foobar", "bAr", { flags: "i" })
// true

Util.factorize()

Factorizes some calculs in a string.

Util.factorize("2y - z * 2 | (4-z) (x/3 *  4) - (4-z)(1 / xy)")
// "2(y-z) | (4-z)((x/3 *  4)-(1 / xy))"

Util.startsWith()

Returns a boolean whether true or false if a string or a line starts with the wanted string with the wanted options or not.

Util.startsWith("foobar", "fOo", { flags: "i" })
// true

Package Sidebar

Install

npm i enregex

Weekly Downloads

27

Version

1.8.3

License

Apache-2.0

Unpacked Size

44.9 kB

Total Files

16

Last publish

Collaborators

  • ations