forked from bethrobson/Head-First-JavaScript-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregexp.html
More file actions
21 lines (18 loc) · 378 Bytes
/
regexp.html
File metadata and controls
21 lines (18 loc) · 378 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Regular Expressions </title>
<script>
var phoneNumber = new RegExp(/^\d{3}-?\d{4}$/);
var amyHome = "555-1212";
var result = amyHome.match(phoneNumber);
console.log(result);
var invalid = "5556-1212";
var result2 = invalid.match(phoneNumber);
console.log(result2);
</script>
</head>
<body>
</body>
</html>