Skip to content

Commit ca38519

Browse files
committed
Update readme, release 0.2.0, close #3
1 parent b54b05b commit ca38519

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Diff for: README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ JavaScript implementation of [Simple Regex](https://simple-regex.com/) :tada::ta
99
> Because of the JavaScript regex engine, there is something different from [Simple Regex](https://simple-regex.com/)
1010
- NOT support `as` to assign capture name.
1111
- NOT support `if already had/if not already had`
12-
- NO `firstMatch`, since in JavaScript `lazy` means non-greedy (matching the fewest possible characters).
12+
- NO `first match` and NO `all lazy`, since in JavaScript `lazy` means non-greedy (matching the fewest possible characters).
1313

1414
## Installation
1515

@@ -26,21 +26,29 @@ The builder can agent `test/exec` method to the generated regex object. Or you c
2626
```js
2727
const SRL = require('srl')
2828
const query = new SRL('letter exactly 3 times')
29-
const regex = query.get() // /[a-z]{3}/
3029

31-
query.test('aaa') // true
32-
query.exec('aaa') // [ 'aaa', index: 0, input: 'aaa' ]
30+
query.isMatching('aaa') // true
31+
query.getMatch('aaa') // [ 'aaa', index: 0, input: 'aaa' ]
3332

3433
query
3534
.digit()
3635
.neverOrMore()
3736
.mustEnd()
38-
.get() // /[a-z]{3}[0-9]*$/
37+
.get() // /[a-z]{3}[0-9]*$/g
3938
```
4039

4140
Required Node 6.0+ for the ES6 support, Or you can use [Babel](http://babeljs.io/) to support Node below 6.0.
4241

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.
42+
Using [Webpack](http://webpack.github.io) and [babel-loader](https://github.com/babel/babel-loader) to pack it if want to use in browsers.
43+
44+
## Additional
45+
46+
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.
47+
48+
- `isMatching` - Validate if the expression matches the given string.
49+
- `getMatch` - Get first match of the given string, like run `regex.exec` once.
50+
- `getMatches` - Get all matches of the given string, like a loop to run `regex.exec`.
51+
- `removeModifier` - Remove specific flag.
4452

4553
## Development
4654

Diff for: lib/Builder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ class Builder {
696696
const regex = this.get()
697697
let temp = null
698698

699-
while(temp = regex.exec(target)) {
699+
while (temp = regex.exec(target)) {
700700
result.push(temp)
701701
}
702702
regex.lastIndex = 0

Diff for: package.json

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

0 commit comments

Comments
 (0)