File: useRegexpGroups.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (74 lines) | stat: -rw-r--r-- 2,123 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
=== tests/cases/conformance/es2018/useRegexpGroups.ts ===
let re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u;
>re : RegExp
>/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u : RegExp

let result = re.exec("2015-01-02");
>result : RegExpExecArray
>re.exec("2015-01-02") : RegExpExecArray
>re.exec : (string: string) => RegExpExecArray
>re : RegExp
>exec : (string: string) => RegExpExecArray
>"2015-01-02" : "2015-01-02"

let date = result[0];
>date : string
>result[0] : string
>result : RegExpExecArray
>0 : 0

let year1 = result.groups.year;
>year1 : string
>result.groups.year : string
>result.groups : { [key: string]: string; }
>result : RegExpExecArray
>groups : { [key: string]: string; }
>year : string

let year2 = result[1];
>year2 : string
>result[1] : string
>result : RegExpExecArray
>1 : 1

let month1 = result.groups.month;
>month1 : string
>result.groups.month : string
>result.groups : { [key: string]: string; }
>result : RegExpExecArray
>groups : { [key: string]: string; }
>month : string

let month2 = result[2];
>month2 : string
>result[2] : string
>result : RegExpExecArray
>2 : 2

let day1 = result.groups.day;
>day1 : string
>result.groups.day : string
>result.groups : { [key: string]: string; }
>result : RegExpExecArray
>groups : { [key: string]: string; }
>day : string

let day2 = result[3];
>day2 : string
>result[3] : string
>result : RegExpExecArray
>3 : 3

let foo = "foo".match(/(?<bar>foo)/)!.groups.foo;
>foo : string
>"foo".match(/(?<bar>foo)/)!.groups.foo : string
>"foo".match(/(?<bar>foo)/)!.groups : { [key: string]: string; }
>"foo".match(/(?<bar>foo)/)! : RegExpMatchArray
>"foo".match(/(?<bar>foo)/) : RegExpMatchArray
>"foo".match : { (regexp: string | RegExp): RegExpMatchArray; (matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; }
>"foo" : "foo"
>match : { (regexp: string | RegExp): RegExpMatchArray; (matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; }
>/(?<bar>foo)/ : RegExp
>groups : { [key: string]: string; }
>foo : string