| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
JavaScript implementation of Simple Regex 🎉🎉🎉
Because of the JavaScript regex engine, there is something different from Simple Regex
npm install srlClass SRL accepts a Simple Regex Language string as input, and return the builder for the query.
The builder can agent test/exec method to the generated regex object. Or you can use get() to take the generated regex object.
const SRL = require('srl')
const query = new SRL('letter exactly 3 times')
query.isMatching('aaa') // true
query.getMatch('aaa') // [ 'aaa', index: 0, input: 'aaa' ]
query
.digit()
.neverOrMore()
.mustEnd()
.get() // /[a-z]{3}[0-9]*$/gRequired Node 6.0+ for the ES6 support, Or you can use Babel to support Node below 6.0.
Using Webpack and babel-loader to pack it if want to use in browsers.
In SRL-JavaScript we apply g flag as default to follow the Simple Regex "standard", so we provide more API to use regex conveniently.
First, clone repo and init submodule for test.
SRL-JavaScript depends on Mocha and Istanbul to test code. You can use them like this:
npm install
npm test # test
npm run coverage # Get coverage locally How to write Rules, see: Test-Rules.
SRL-JavaScript is published under the MIT license. See LICENSE for more information.
| Back | FazBrowse Home | New Git URL |