You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,12 +12,17 @@ This is an official plugin for [Regex+](https://github.com/slevithan/regex) that
12
12
Recursive matching is added to a regex via one of the following (the recursion depth limit is provided in place of *`N`*):
13
13
14
14
-`(?R=N)` — Recursively match the entire regex at this position.
15
-
-`\g<name&R=N>` or `\g<number&R=N>` — Recursively match the contents of the group referenced by name or number at this position.
16
-
- The `\g` subroutine must be *within* the referenced group.
15
+
-`\g<name&R=N>` or `\g<number&R=N>` — Recursively match the contents of the group referenced by name or number at this position. The `\g` subroutine must be *within* the referenced group.
17
16
18
-
Multiple uses of recursion within the same pattern are allowed if they are non-overlapping. Named captures and backreferences are supported within recursion, and 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.
17
+
Multiple uses of recursion within the same pattern are allowed if they are non-overlapping. Named captures and backreferences are supported within recursion, and are independent per depth level. So e.g. `match.groups.name` is the value captured by group `name` at the top level of the recursion stack.
19
18
20
-
## Install and use
19
+
## 📜 Contents
20
+
21
+
-[Install and use](#️-install-and-use)
22
+
-[Examples](#-examples)
23
+
-[Direct use, without Regex+](#️-direct-use-without-regex)
24
+
25
+
## 🕹️ Install and use
21
26
22
27
```sh
23
28
npm install regex regex-recursion
@@ -58,7 +63,7 @@ const re = regex({plugins: [recursion]})`…`;
58
63
```
59
64
</details>
60
65
61
-
## Examples
66
+
## 🪧 Examples
62
67
63
68
### Match an equal number of two different subpatterns
Following is an alternative that matches the same strings, but adds a nested quantifier. It then uses an atomic group to prevent this nested quantifier from creating the potential for [catastrophic backtracking](https://www.regular-expressions.info/catastrophic.html). Since the example above doesn't need a nested quantifier, this is not an improvement but merely an alternative that shows how to deal with the general problem of nested quantifiers with multiple ways to divide matches of the same strings.
108
+
Following is an alternative that matches the same strings, but adds a nested quantifier. It then uses an atomic group to prevent the nested quantifier from creating the potential for [catastrophic backtracking](https://www.regular-expressions.info/catastrophic.html). Since the example above doesn't *need* a nested quantifier, this isn't an improvement but merely an alternative that shows how to deal with the general problem of nested quantifiers that create multiple ways to divide matches of the same strings.
Because the generated pattern is used without Regex+, you can't include extended syntax like insignificant whitespace, atomic groups, possessive quantifiers, or non-recursive subroutines.
178
+
179
+
## 🏷️ About
180
+
181
+
regex-recursion was created by [Steven Levithan](https://github.com/slevithan).
182
+
183
+
If you want to support this project, I'd love your help by contributing improvements, sharing it with others, or [sponsoring](https://github.com/sponsors/slevithan) ongoing development.
0 commit comments