Skip to content

Commit ba81904

Browse files
committed
Update readme, release 0.2.1, close #6
1 parent 4fe0e8d commit ba81904

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

README.md

+36-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ JavaScript implementation of [Simple Regex](https://simple-regex.com/) :tada::ta
77
[![codecov](https://codecov.io/gh/SimpleRegex/SRL-JavaScript/branch/master/graph/badge.svg)](https://codecov.io/gh/SimpleRegex/SRL-JavaScript)
88

99
> 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.
10+
- Support `as` to assign capture name with CODE but not regex engine.
1111
- NOT support `if already had/if not already had`
1212
- NO `first match` and NO `all lazy`, since in JavaScript `lazy` means non-greedy (matching the fewest possible characters).
1313

@@ -46,10 +46,45 @@ Using [Webpack](http://webpack.github.io) and [babel-loader](https://github.com/
4646
In SRL-JavaScript we apply `g` flag as default to follow the [Simple Regex](https://simple-regex.com/) "standard", so we provide more API to use regex conveniently.
4747

4848
- `isMatching` - Validate if the expression matches the given string.
49+
50+
```js
51+
const query = new SRL('starts with letter twice')
52+
query.isMatching(' aa') // false
53+
query.isMatching('bbb') // true
54+
```
55+
4956
- `getMatch` - Get first match of the given string, like run `regex.exec` once.
57+
58+
```js
59+
const query = new SRL('capture (letter twice) as word whitespace')
60+
61+
query.getMatch('aa bb cc dd') // [ 'aa ', 'aa', index: 0, input: 'aa bb cc dd', word: 'aa' ]
62+
```
63+
5064
- `getMatches` - Get all matches of the given string, like a loop to run `regex.exec`.
65+
66+
```js
67+
const query = new SRL('capture (letter twice) as word whitespace')
68+
69+
query.getMatches('aa bb cc dd')
70+
/**
71+
* [
72+
* [ 'aa ', 'aa', index: 0, input: 'aa bb cc dd', word: 'aa' ],
73+
* [ 'bb ', 'bb', index: 3, input: 'aa bb cc dd', word: 'bb' ],
74+
* [ 'cc ', 'cc', index: 6, input: 'aa bb cc dd', word: 'cc' ]
75+
* ]
76+
*/
77+
```
78+
5179
- `removeModifier` - Remove specific flag.
5280

81+
```js
82+
const query = new SRL('capture (letter twice) as word whitespace')
83+
84+
query.removeModifier('g')
85+
query.get() // /([a-z]{2})\s/
86+
```
87+
5388
## Development
5489

5590
First, clone repo and init submodule for test.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "srl",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Simple Regex Language",
55
"main": "lib/SRL.js",
66
"scripts": {

test/rules-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function runAssertions(data) {
124124
// })
125125
const item = expected[index]
126126

127-
for (let key in item) {
127+
for (const key in item) {
128128
if (typeof key === 'number') {
129129
assert.equal(
130130
capture[key + 1],

0 commit comments

Comments
 (0)