We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0a81076 + 534777f commit f133f4bCopy full SHA for f133f4b
README.md
@@ -0,0 +1,20 @@
1
+# typed-regexp
2
+A typescript package that strongly restricts types of regular expressions.
3
+
4
+## Example
5
+```ts
6
+import { TypedRegExp } from "typed-regexp";
7
8
+const string = "string to match";
9
+const regexp = new TypedRegExp<[`{${string}`],{group:"a"|"b"}>("(?<group>[ab])({.*)");
10
+/* can also be this:
11
+const regexp = /(?<group>[ab])({.*)/ as TypedRegExp<[`{${string}`],{group:"a"|"b"}>;
12
+*/
13
+const match = string.match(regexp);
14
+if (match) {
15
+ const namedGroup = match.groups.group;
16
+ // => "a"|"b"
17
+ const group = match[1];
18
+ // => `{${string}`
19
+}
20
+```
0 commit comments