https://github.com/pmarkert/rhythmic
Fluent Regex builder for node.js
https://github.com/pmarkert/rhythmic
Last synced: about 22 hours ago
JSON representation
Fluent Regex builder for node.js
- Host: GitHub
- URL: https://github.com/pmarkert/rhythmic
- Owner: pmarkert
- Created: 2017-02-10T02:51:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-10T02:54:54.000Z (over 9 years ago)
- Last Synced: 2025-07-12T16:48:51.580Z (12 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rhythmic
Fluent Regex builder for node.js
When completed, this project will allow for a fluent interface for building regular expressions. For now, this is a placeholder. :)
```javascript
var rhy = require("rhythmic");
var anything_but_pipe_or_quote = "[^\\|'\"`]*";
var params = (index) => rhy.capture(rhy.zero_or_more(rhy.nonCapturingGroup(anything_but_pipe_or_quote + rhy.optional(rhy.quoted(".*?",index)))));
var parenthetical_params = rhy.nonCapturingGroup(rhy.parenthetical(params(2)));
var comma_params = rhy.nonCapturingGroup("," + params(5));
var pipe_params = rhy.choice_of(parenthetical_params, comma_params);
var pipe_expression = rhy.capture(rhy.identifier()) + rhy.space() + rhy.optional(rhy.nonCapturingGroup(pipe_params));
var pipe_symbol = "\\|";
var pattern = rhy.nonCapturingGroup(pipe_symbol + rhy.space() + pipe_expression + rhy.space());
```