carol-js
v2.0.0
Published
A powerful, small tool for building regular expressions.
Maintainers
Readme
carol-js
A powerful, small tool for building regular expressions.
- It maintains its readability even with complex regular expressions.
- It build a RegExp object by combining functions.
- It provides a package of ES modules.
import C from "carol-js";
const hex = C(/[0-9a-f][0-9a-f]/);
const uuid = C.seq([
hex.many({ length: 4 }),
C.token(/-/),
hex.many({ length: 2 }),
C.token(/-/),
hex.many({ length: 2 }),
C.token(/-/),
hex.many({ length: 2 }),
C.token(/-/),
hex.many({ length: 6 }),
]);
const regex = uuid.toRegex({ flags: "i", exact: true });
assert.strictEqual(
regex.source,
"^(?:[0-9a-f][0-9a-f]){4}-(?:[0-9a-f][0-9a-f]){2}-(?:[0-9a-f][0-9a-f]){2}-(?:[0-9a-f][0-9a-f]){2}-(?:[0-9a-f][0-9a-f]){6}$"
);
assert.strictEqual(regex.flags, "i");Get Started
Install package of carol-js to your project.
npm i carol-jsImport the package to your TypeScript or JavaScript(ES modules) source files.
import C from 'carol-js';Enjoy carol-js!
Documents
Test
git clone https://github.com/marihachi/carol-js.git
cd carol-js
npm i
npm run build
npm testLicense
MIT
