regops
v1.2.1
Published
A small javascript library for performing operations on regular expressions
Downloads
10
Maintainers
Readme
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:
Name | Type |
------ | ------ |
str
| string |
Returns: string
bracket
▸ bracket(str
: string): string
Defined in regops.ts:9
Put non-capturing brackets around a regex source string.
Parameters:
Name | Type |
------ | ------ |
str
| string |
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:
Name | Type |
------ | ------ |
operand
| RegExp | string |
groupName
| string |
Returns: RegExp
concat
▸ concat(...operands
: null | string | RegExp[]): RegExp
Defined in regops.ts:22
Concatenate a list a of regular expressions.
Parameters:
Name | Type |
------ | ------ |
...operands
| null | 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:
Name | Type |
------ | ------ |
...operands
| null | 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:
Name | Type |
------ | ------ |
operand
| RegExp | string |
Returns: RegExp
kleene
▸ kleene(operand
: RegExp | string): string
Defined in regops.ts:56
Apply Kleene closure (*) operator to a regular expression.
Parameters:
Name | Type |
------ | ------ |
operand
| RegExp | 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:
Name | Type |
------ | ------ |
stem
| RegExp | string |
...optionalAppendages
| null | 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:
Name | Type |
------ | ------ |
operand
| RegExp | string |
delimiter
| string |
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:
Name | Type |
------ | ------ |
...operands
| string | 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:
Name | Type |
------ | ------ |
operand
| RegExp | string |
Returns: RegExp
optional
▸ optional(operand
: RegExp | string): string
Defined in regops.ts:49
Apply OPTIONAL (?) operator to a regular expressions.
Parameters:
Name | Type |
------ | ------ |
operand
| RegExp | 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:
Name | Type |
------ | ------ |
stem
| RegExp | string |
...optionalAppendages
| null | string | RegExp[] |
Returns: RegExp
or
▸ or(...operands
: null | string | RegExp[]): RegExp
Defined in regops.ts:40
Combine regular expressions with OR (|) operator.
Parameters:
Name | Type |
------ | ------ |
...operands
| null | 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:
Name | Type |
------ | ------ |
list
| null | 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:
Name | Type |
------ | ------ |
operand
| RegExp | 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:
Name | Type |
------ | ------ |
operand
| RegExp | string |
Returns: RegExp