-
Notifications
You must be signed in to change notification settings - Fork 1
/
RegularExpressionIIIHR.js
80 lines (57 loc) · 1.44 KB
/
RegularExpressionIIIHR.js
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
75
76
77
78
79
/*
Task
Complete the function in the editor below by returning a RegExp object, , that matches every integer in some string .
Constraints
The length of string is .
It's guaranteed that string contains at least one integer.
Output Format
The function must return a RegExp object that matches every integer in some string .
Sample Input 0
102, 1948948 and 1.3 and 4.5
Sample Output 0
102
1948948
1
3
4
5
Explanation 0
When we call match on string and pass the correct RegExp as our argument, it returns the following array of results: [ '102', '1948948', '1', '3', '4', '5' ].
Sample Input 1
1 2 3
Sample Output 1
1
2
3
Explanation 1
When we call match on string and pass the correct RegExp as our argument, it returns the following array of results: [ '1', '2', '3' ].
*/
// SOLUTION
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', _ => {
inputString = inputString.trim().split('\n').map(string => {
return string.trim();
});
main();
});
function readLine() {
return inputString[currentLine++];
}
function regexVar() {
/*
* Declare a RegExp object variable named 're'
* It must match ALL occurrences of numbers in a string.
*/
let re = /([0-9])+/g;
/*
* Do not remove the return statement
*/
return re;
}