Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit a7a6348

Browse files
committed
Update readme
1 parent f41b991 commit a7a6348

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,62 @@
1-
# JavaScript
2-
JavaScript implementation of SRL.
1+
# SRL-JavaScript
2+
3+
JavaScript implementation of [Simple Regex](https://simple-regex.com/) :tada::tada::tada:
4+
5+
[![npm version](https://badge.fury.io/js/srl.svg)](https://badge.fury.io/js/srl)
6+
[![Build Status](https://travis-ci.org/SimpleRegex/SRL-JavaScript.svg?branch=master)](https://travis-ci.org/SimpleRegex/SRL-JavaScript)
7+
[![codecov](https://codecov.io/gh/SimpleRegex/SRL-JavaScript/branch/master/graph/badge.svg)](https://codecov.io/gh/SimpleRegex/SRL-JavaScript)
8+
9+
> Because of the JavaScript regex engine, there is something different from [Simple Regex](https://simple-regex.com/)
10+
- NOT support `as` to assign capture name.
11+
- NOT support `if already had/if not already had`
12+
- NO `firstMatch`, since in JavaScript `lazy` means non-greedy (matching the fewest possible characters).
13+
14+
## Installation
15+
16+
```sh
17+
npm install srl
18+
```
19+
20+
## Usage
21+
22+
Class SRL accepts a Simple Regex Language string as input, and return the builder for the query.
23+
24+
The builder can agent `test/exec` method to the generated regex object. Or you can use `get()` to take the generated regex object.
25+
26+
```js
27+
const SRL = require('srl')
28+
const query = new SRL('letter exactly 3 times')
29+
const regex = query.get() // /[a-z]{3}/
30+
31+
query.test('aaa') // true
32+
query.exec('aaa') // [ 'aaa', index: 0, input: 'aaa' ]
33+
34+
query
35+
.digit()
36+
.neverOrMore()
37+
.mustEnd()
38+
.get() // /[a-z]{3}[0-9]*$/
39+
```
40+
41+
Required Node 6.0+ for the ES6 support, Or you can use [Babel](http://babeljs.io/) to support Node below 6.0.
42+
43+
Using [Webpack](http://webpack.github.io) and [babel-loader](https://github.com/babel/babel-loader) to pack it if want to use in browsers.
44+
45+
## Development
46+
47+
First, clone repo and init submodule for test.
48+
49+
SRL-JavaScript depends on [Mocha](http://mochajs.org) and [Istanbul](https://github.com/gotwarlost/istanbul) to test code. You can use them like this:
50+
51+
```sh
52+
npm install
53+
54+
npm test # test
55+
npm run coverage # Get coverage locally
56+
```
57+
58+
How to write Rules, see: [Test-Rules](https://github.com/SimpleRegex/Test-Rules).
59+
60+
## License
61+
62+
SRL-JavaScript is published under the MIT license. See LICENSE for more information.

0 commit comments

Comments
 (0)