https://github.com/marihachi/carol-js
A powerful, small tool for building regular expressions.
https://github.com/marihachi/carol-js
builder esm regex regular-expression tools typescript utility
Last synced: 3 months ago
JSON representation
A powerful, small tool for building regular expressions.
- Host: GitHub
- URL: https://github.com/marihachi/carol-js
- Owner: marihachi
- License: mit
- Created: 2023-11-16T15:06:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-12T12:50:00.000Z (5 months ago)
- Last Synced: 2025-08-09T02:54:04.419Z (4 months ago)
- Topics: builder, esm, regex, regular-expression, tools, typescript, utility
- Language: TypeScript
- Homepage:
- Size: 109 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
```js
import C from "carol-js";
const hex = C.token(/[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
1. Install package of carol-js to your project.
```sh
npm i carol-js
```
2. Import the package to your TypeScript or JavaScript(ES modules) source files.
```js
import C from 'carol-js';
```
3. Enjoy carol-js!
## Documents
- [API reference](https://github.com/marihachi/carol-js/blob/7ab6d7796a254764f4372e74220f7302d63b2669/doc/api.md)
- [Usage](https://github.com/marihachi/carol-js/blob/7ab6d7796a254764f4372e74220f7302d63b2669/doc/usage.md)
## Test
```sh
git clone https://github.com/marihachi/carol-js.git
cd carol-js
npm i
npm run build
npm test
```
## License
MIT