Skip to content

Commit 77c9288

Browse files
committed
Readme tweaks
1 parent 76df72d commit 77c9288

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
[![npm version][npm-version-src]][npm-version-href]
44
[![bundle][bundle-src]][bundle-href]
55

6-
This is an official plugin for the [`regex`](https://github.com/slevithan/regex) library that adds support for recursive matching up to a specified max depth *N*, where *N* must be between 2 and 100. Generated regexes are native `RegExp` instances, and support all JavaScript regular expression features except numbered backreferences (support could be added in future versions).
6+
This is an official plugin for the [`regex`](https://github.com/slevithan/regex) library that adds support for recursive matching up to a specified max depth *N*, where *N* can be between 2 and 100. Generated regexes are native `RegExp` instances, and support all JavaScript regular expression features except numbered backreferences (support could be added in future versions).
77

88
Recursive matching is added to a regex via one of the following:
99

1010
- `(?R=N)` — Recursively match the entire regex at this position.
11-
- `\g<name&R=N>`, `\g<N&R=N>` — Recursively match the contents of the group referenced by name or number at this position.
12-
- The `\g` subroutine must be called *within* the referenced group.
11+
- `\g<name&R=N>` or `\g<number&R=N>` — Recursively match the contents of the group referenced by name or number at this position.
12+
- The `\g` subroutine must be *within* the referenced group.
1313

14-
Recursive matching supports named captures and named backreferences, which are independent per depth level. So e.g. `groups.name` on a match object is the value captured by group `name` at the top level of the recursion stack.
14+
The recursion depth limit is provided where *`N`* is shown above.
15+
16+
Recursive matching supports named captures and backreferences, which are independent per depth level. So e.g. `groups.name` on a match object is the value captured by group `name` at the top level of the recursion stack.
1517

1618
## Install and use
1719

@@ -69,7 +71,7 @@ re.test('aaabbb'); // → true
6971
re.test('aaabb'); // → false
7072
```
7173

72-
Note the `^` and `$` anchors outside of the recursive subpattern.
74+
Notice the `^` and `$` anchors outside of the recursive subpattern.
7375

7476
### Match balanced parentheses
7577

@@ -98,7 +100,7 @@ const parens = regex({flags: 'g', plugins: [recursion]})`
98100

99101
This matches sequences of non-parens in one step with the nested `+` quantifier, and avoids backtracking into these sequences by wrapping it with an atomic group `(?>…)`. Given that what the nested quantifier `+` matches overlaps with what the outer group can match with its `*` quantifier, the atomic group is important here. It avoids exponential backtracking when matching long strings with unbalanced parens.
100102

101-
Atomic groups are provided by the base `regex` library.
103+
[Atomic groups](https://github.com/slevithan/regex#atomic-groups) are provided by the base `regex` library.
102104

103105
### Match palindromes
104106

@@ -137,7 +139,7 @@ Notice the `\b` word boundaries outside of the recursive subpattern.
137139

138140
<!-- Badges -->
139141

140-
[npm-version-src]: https://img.shields.io/npm/v/regex-recursion
142+
[npm-version-src]: https://img.shields.io/npm/v/regex-recursion?color=78C372
141143
[npm-version-href]: https://npmjs.com/package/regex-recursion
142-
[bundle-src]: https://img.shields.io/bundlephobia/minzip/regex-recursion?label=minzip
143-
[bundle-href]: https://bundlephobia.com/package/regex-recursion
144+
[bundle-src]: https://img.shields.io/bundlejs/size/regex-recursion?color=78C372&label=minzip
145+
[bundle-href]: https://bundlejs.com/?q=regex-recursion&treeshake=[*]

0 commit comments

Comments
 (0)