reglax
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

reglax

☕ Relax and write some Regex

npm Travis CI David License

Creates regular expressions that are composable, reusable, and commentable.

Usage

npm install reglax
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.

Examples

test/index.spec.js can be a good reference.

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
// 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

Donate

Buy Me A Coffee

/reglax/

    Package Sidebar

    Install

    npm i reglax

    Weekly Downloads

    4

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    20.8 kB

    Total Files

    19

    Last publish

    Collaborators

    • exuanbo