https://github.com/exuanbo/reglax
☕ Relax and write some Regex
https://github.com/exuanbo/reglax
regex regular-expression
Last synced: 3 months ago
JSON representation
☕ Relax and write some Regex
- Host: GitHub
- URL: https://github.com/exuanbo/reglax
- Owner: exuanbo
- License: mit
- Created: 2020-09-01T08:11:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-05T01:59:42.000Z (3 months ago)
- Last Synced: 2025-04-06T06:57:04.176Z (3 months ago)
- Topics: regex, regular-expression
- Language: TypeScript
- Homepage:
- Size: 254 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reglax
> ☕ Relax and write some Regex
[](https://www.npmjs.com/package/reglax)
[](https://travis-ci.com/github/exuanbo/reglax)
[](https://david-dm.org/exuanbo/reglax)
[](https://github.com/exuanbo/reglax/blob/master/LICENSE)Creates regular expressions that are composable, reusable, and commentable.
## Usage
```sh
npm install reglax
``````js
const {
matchers,
flags,
whole,
repeat,
alpha,
numeric,
and,
or,
wildcard,
extra,
capture,
group,
look,
regex
} = require('reglax')// or
import { something } from 'reglax'
```### API
See generated [typedoc](https://exuanbo.github.io/reglax/modules/_index_.html).
### Examples
[test/index.spec.js](https://github.com/exuanbo/reglax/blob/master/test/index.spec.js) can be a good reference.
```js
regex(
whole(
or(numeric(7), capture(alpha(0, 3)), extra(matchers.ANY, matchers.LAZY))
),
and(flags.GLOBAL, flags.INSENSITIVE)
)
// -> /^\d{7}|([A-z]{0,3})|.+?$/gi
``````js
// Matches all New York Driver's licenses
regex(
or(
and(alpha(1), numeric(7)),
and(alpha(1), numeric(18)),
and(numeric(8, 9)),
and(numeric(16)),
and(alpha(8))
)
)
// -> /[A-z]{1}\d{7}|[A-z]{1}\d{18}|\d{8,9}|\d{16}|[A-z]{8}/
```## License
[MIT](https://github.com/exuanbo/reglax/blob/master/LICENSE)
## Donate