1.2.1 • Published 6 years ago

regops v1.2.1

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

RegOps

Perform basic operations to manipulate regular expressions.

Install

npm i regops

Functions

autoBracket

autoBracket(str: string): string

Defined in regops.ts:14

If necessary, put non-capturing brackets around a regex source string.

Parameters:

NameType
strstring

Returns: string


bracket

bracket(str: string): string

Defined in regops.ts:9

Put non-capturing brackets around a regex source string.

Parameters:

NameType
strstring

Returns: string


capture

capture(operand: RegExp | string, groupName: string): RegExp

Defined in regops.ts:125

Surround a regular expression with capturing parentheses, optionally specifying a group name.

Parameters:

NameType
operandRegExp | string
groupNamestring

Returns: RegExp


concat

concat(...operands: null | string | RegExp[]): RegExp

Defined in regops.ts:22

Concatenate a list a of regular expressions.

Parameters:

NameType
...operandsnull | string | RegExp[]

Returns: RegExp


concatSpaced

concatSpaced(...operands: null | string | RegExp[]): RegExp

Defined in regops.ts:31

Concatenate a list of regular expressions with a single-space (' ') delimiter.

Parameters:

NameType
...operandsnull | string | RegExp[]

Returns: RegExp


initial

initial(operand: RegExp | string): RegExp

Defined in regops.ts:113

Add a ^ marker at the beginning of a regular expression, so that it must match the beginning of a string.

Parameters:

NameType
operandRegExp | string

Returns: RegExp


kleene

kleene(operand: RegExp | string): string

Defined in regops.ts:56

Apply Kleene closure (*) operator to a regular expression.

Parameters:

NameType
operandRegExp | string

Returns: string


kleeneConcatSpaced

kleeneConcatSpaced(stem: RegExp | string, ...optionalAppendages: null | string | RegExp[]): RegExp

Defined in regops.ts:95

Concatenate an item with itself any number of times (using kleene closure *) using a single-space (' ') as a delimiter.

Parameters:

NameType
stemRegExp | string
...optionalAppendagesnull | string | RegExp[]

Returns: RegExp


kleeneJoin

kleeneJoin(operand: RegExp | string, delimiter: string): RegExp

Defined in regops.ts:67

Apply Kleene repetitions of a regular expression with some specified delimiter.

Parameters:

NameType
operandRegExp | string
delimiterstring

Returns: RegExp


kleenePoliteList

kleenePoliteList(...operands: string | RegExp[]): RegExp

Defined in regops.ts:74

Create a "polite list" (form: X, X, X and X) using Kleene closure to allow any number of items.

Parameters:

NameType
...operandsstring | RegExp[]

Returns: RegExp


kleeneSpaced

kleeneSpaced(operand: RegExp | string): RegExp

Defined in regops.ts:63

Apply Kleene closure (*) operator to a regular expression, delimiting repetitions with a single-space (' ')

Parameters:

NameType
operandRegExp | string

Returns: RegExp


optional

optional(operand: RegExp | string): string

Defined in regops.ts:49

Apply OPTIONAL (?) operator to a regular expressions.

Parameters:

NameType
operandRegExp | string

Returns: string


optionalConcatSpaced

optionalConcatSpaced(stem: RegExp | string, ...optionalAppendages: null | string | RegExp[]): RegExp

Defined in regops.ts:83

Concatenate a list of regular expressions with optional (?) modifiers.

Parameters:

NameType
stemRegExp | string
...optionalAppendagesnull | string | RegExp[]

Returns: RegExp


or

or(...operands: null | string | RegExp[]): RegExp

Defined in regops.ts:40

Combine regular expressions with OR (|) operator.

Parameters:

NameType
...operandsnull | string | RegExp[]

Returns: RegExp


sourcify

sourcify(list: null | String | RegExp[]): string[]

Defined in regops.ts:2

Convert a list of convert regexs to their source strings.

Parameters:

NameType
listnull | String | RegExp[]

Returns: string[]


terminal

terminal(operand: RegExp | string): RegExp

Defined in regops.ts:119

Add a $ marker at the end of a regular expression, so that it matches the end of a string.

Parameters:

NameType
operandRegExp | string

Returns: RegExp


whole

whole(operand: RegExp | string): RegExp

Defined in regops.ts:107

Add ^ and $ markers either side of a regular expression so that it must match an entire string.

Parameters:

NameType
operandRegExp | string

Returns: RegExp