# regex-factorize

> Factorize regexes with lists of numbers into more performant factorized Regexes

Latest version **1.0.1** (published 2022-06-08) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install regex-factorize
pnpm add regex-factorize
yarn add regex-factorize
bun add regex-factorize
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-06-08 |
| First published | 2022-06-01 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Misfits09 |
| Maintainers | misfits09 |

## Links

- npm: https://www.npmjs.com/package/regex-factorize
- Repository: https://github.com/Misfits09/regex-factorize
- npm.io page: https://npm.io/package/regex-factorize

## Recent versions

- 1.0.1 (latest) — 2022-06-08
- 1.0.0 — 2022-06-01
- 0.0.3 — 2022-06-01
- 0.0.2 — 2022-06-01
- 0.0.1 — 2022-06-01

## README

# Regex factorization of numbers

Factorize regexes with lists of numbers into more performant factorized Regexes

## Installation

Install with one of the following command :

```bash
npm install regex-factorize
```

or with `yarn`

```bash
yarn add regex-factorize
```

## Importation

Then you have access to two methods that can be imported with :

```ts
import { regexFromNumberArray, simplifyExistingRegex } from "regex-factorize";
```

or

```js
const {
  regexFromNumberArray,
  simplifyExistingRegex,
} = require("regex-factorize");
```

## Usage

- `regexFromNumberArray(array)` : Takes into argument an array of numbers and outputs an optimized regex

  _Example : `regexFromNumberArray([123,124,125,5678,5689])` gives : `1(2([3-5]))|5(6(78|89))`_

- `simplifyExistingRegex(string)` : Takes into argument an existing regex and simplify segments with only digits in a OR.

  _Example 1: `regexFromNumberArray("123|124|125|5678|5689")` gives : `1(2([3-5]))|5(6(78|89))`_

  _Example 2: `regexFromNumberArray("a(123|124|125|5678|5689)")` gives : `a(1(2([3-5]))|5(6(78|89)))`_

---
_Source: https://npm.io/package/regex-factorize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
