File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ As direct dependency: `npm i typed-regexp`
77``` ts
88import { TypedRegExp } from " typed-regexp" ;
99
10- const regexp = new TypedRegExp <[` {${string } ` ],{group : " a" | " b" }>(" (?<group >[ab])({.*)" );
10+ const regexp = new TypedRegExp <[` {${string } ` ],{name : " a" | " b" }>(" (?<name >[ab])({.*)" );
1111const match = " string to match" .match (regexp );
1212if (match ) {
13- const namedGroup = match .groups .group ;
13+ const namedGroup = match .groups .name ;
1414 // => "a"|"b"
1515 const group = match [1 ];
1616 // => `{${string}`
@@ -21,10 +21,10 @@ or as dev dependency: `npm i -D typed-regexp`
2121``` ts
2222import type { TypedRegExp } from " typed-regexp" ;
2323
24- const regexp = / (? <group >[ab ])({.*)/ as TypedRegExp <[` {${string } ` ],{group: " a" | " b" }>;
24+ const regexp = / (? <name >[ab ])({.*)/ as TypedRegExp <[` {${name } ` ],{group: " a" | " b" }>;
2525const match = " string to match" .match (regexp );
2626if (match ) {
27- const namedGroup = match .groups .group ;
27+ const namedGroup = match .groups .name ;
2828 // => "a"|"b"
2929 const group = match [1 ];
3030 // => `{${string}`
You can’t perform that action at this time.
0 commit comments