-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregExp.html
More file actions
43 lines (31 loc) · 1.05 KB
/
Copy pathregExp.html
File metadata and controls
43 lines (31 loc) · 1.05 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
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Regular Expressions</h2>
<p>The test() method returns true if it finds a match, otherwise false.</p>
<p>Search a string for the character "e":</p>
<p id="demo"></p>
<script>
let text = "aaabbcccccd";
let pattern = /[a]{3}[b]{2}[c]{5}[d]{1}/;
let result = pattern.test(text);
document.getElementById("demo").innerHTML += result;
let text1 ="abcabcabca321765";
let pattern1 =/abcabcabca321765/g;
let result1 = pattern1.test(text1);
document.getElementById("demo").innerHTML +=("<br>"+result1);
let text2 = prompt("Enter the password :-"+"<br>");
let pattern2 =/[A-Z]{2,}[a-z]{2,}[. , ^ , $ , * , + , ? , { } , [ ] , ( ) , | , \ ,@]{2,}/g;
let result2 = pattern2.test(text2);
if(result2)
{
document.getElementById("demo").innerHTML +=("<br>"+result1);
}
else
{
alert("make sure the following instructions :-"+"<br>"+"1.password must contain atleast two upercase charecter ,two lowercase charecter and two speacial charecter "+"<br>"+
"2. your password should be of max 12 char" ) ;
}
</script>
</body>
</html>