-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern.php
More file actions
59 lines (46 loc) · 1.27 KB
/
pattern.php
File metadata and controls
59 lines (46 loc) · 1.27 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
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
$pattern="/a*c/";
$string="a.c";
if(preg_match($pattern,$string)){
echo "Match Found:";
}
else{
echo "Not Match";
}
$word="/hello/";
$str="hEllo";
echo preg_match($word,$str);
$word1="/student$/";
$str1="hello student";
echo preg_match($word1,$str1);
$word2="/a*/"; // This will always match the string return true
$str2="77";
echo preg_match($word2,$str2);
$word3="/a+/"; // this will match first value you can write any value after a
$str3="abchdhd";
echo preg_match($word3,$str3);
$word4="/a?/";
$str4="AB";
echo preg_match($word4,$str4);
$word5="/[a]/";
$str5="abk";
echo preg_match($word5,$str5);
$word6="/a|b/"; // This is work like and operator
$str6="klk";
echo preg_match($word6,$str6);
$word6="/a{3}/"; // This will minimum 3 values in a line and not limit in maximum
$str6="klkaaae";
echo preg_match($word6,$str6);
$word6="/s{3,5}/";
$str6="ancsssssssss";
echo preg_match($word6,$str6);
$word6="/(abc)/";
$str6="Aabc";
echo preg_match($word6,$str6);
$word6="/[a-z]/";
$str6="klm";
echo preg_match($word6,$str6);
$word7="/[0-9]/";
$str7="100";
echo preg_match($word7,$str7);
?>