Skip to content

Commit 57ecc48

Browse files
Completed Day 8 on 13/12/2020
1 parent 15641d4 commit 57ecc48

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

Diff for: Day 8/Problem 1/Regular_expression_1.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Regular Expression 1</title>
7+
</head>
8+
<body>
9+
<h1>Day 8</h1>
10+
<h4>Problem 1</h4>
11+
</body>
12+
<script src="script.js"></script>
13+
</html>

Diff for: Day 8/Problem 1/script.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function regexVar() {
2+
3+
var re;
4+
5+
re = new RegExp("^([a,e,i,o,u]).*\\1$");
6+
7+
return re;
8+
}
9+
10+
function main() {
11+
const re = regexVar();
12+
const s = readLine();
13+
14+
console.log(re.test(s));
15+
}

Diff for: Day 8/Problem 2/Regular_Expression_2.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Regular Expressions 2</title>
7+
</head>
8+
<body>
9+
<h1>Day 8</h1>
10+
<h4>Problem 2</h4>
11+
</body>
12+
<script src="script.js"></script>
13+
</html>

Diff for: Day 8/Problem 2/script.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function regexVar() {
2+
3+
var re;
4+
re = new RegExp("^(Mr|Mrs|Ms|Dr|Er)\\.[a-zA-Z]+$");
5+
6+
return re;
7+
}
8+
9+
function main() {
10+
const re = regexVar();
11+
const s = "Dr#Joseph";
12+
13+
console.log(!!s.match(re));
14+
}

Diff for: Day 8/Problem 3/Regular_Expression_3.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Regular expressions 3</title>
7+
</head>
8+
<body>
9+
<h1>Day 8</h1>
10+
<h4>Problem 3</h4>
11+
</body>
12+
<script src="script.js"></script>
13+
</html>

Diff for: Day 8/Problem 3/script.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function regexVar() {
2+
3+
var re;
4+
re = new RegExp('\\d+','\g');
5+
6+
return re;
7+
}
8+
9+
function main() {
10+
const re = regexVar();
11+
const s = readLine();
12+
13+
const r = s.match(re);
14+
15+
for (const e of r) {
16+
console.log(e);
17+
}
18+
}

0 commit comments

Comments
 (0)