npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

regops

v1.2.1

Published

A small javascript library for performing operations on regular expressions

Downloads

10

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