1.8.3 • Published 3 years ago

enregex v1.8.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

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

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

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"]

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

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

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

Finds beacons and their content into an array.

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

Returns URLs by given parameters.

console.log(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']

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

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

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
1.8.3

3 years ago

1.8.2

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.5

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.3.2

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.0

3 years ago