html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
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
function test(re, testCases){
console.log("--- Starting tests ---\n");
for(let i = 0; i < testCases.length; i++){
console.log(`${testCases[i]} => ${re.test(testCases[i])}`);
}
console.log("\n--- Tests ended ---\n")
}
// must have at least one leading 1
const re1 = new RegExp(/^((1)+(00)*)*$/);
const passingTestCases1 = ["1001110000100", "11100100100000011111110000", "11001100001111"];
const failingTestCases1 = ["00110000", "100100001000"];
console.log("must have at least one leading 1");
console.log("should be 'true':");
test(re1, passingTestCases1);
console.log("should be 'false':");
test(re1, failingTestCases1);
// leading 1 is not required
const re2 = new RegExp(/^((1)*(00)*)*$/);
const passingTestCases2 = ["1001110000100", "11100100100000011111110000", "1111111001100110000", "00110000"];
const failingTestCases2 = ["100100001000", "11001100001111000"];
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run