forked from patdryburgh/hitchens
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregexp.html
More file actions
46 lines (44 loc) · 1.46 KB
/
regexp.html
File metadata and controls
46 lines (44 loc) · 1.46 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Regex Matcher</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 20px;
text-align: center;
}
input, button {
margin: 10px;
padding: 8px;
font-size: 16px;
}
</style>
</head>
<body>
<h2>Regular Expression Matcher</h2>
<label for="regex">Regular Expression:</label>
<input type="text" id="regex" value=".*@.*[.].*" /><br>
<label for="inputString">Input String:</label>
<input type="text" id="inputString" value="leo@companion.net" /><br>
<button onclick="checkMatch()">Check Match</button>
<p id="result"></p>
<script>
function checkMatch() {
let regexInput = document.getElementById("regex").value;
let inputString = document.getElementById("inputString").value;
try {
let regex = new RegExp(regexInput);
let isMatch = regex.test(inputString);
document.getElementById("result").textContent = isMatch ? "✅ Match!" : "❌ No Match!";
} catch (error) {
console.log(error)
document.getElementById("result").textContent = "⚠️ Invalid Regular Expression!";
}
}
</script>
</body>
</html>