preg_match_all php code example
Example 1: preg_match in php
<?php
$str = "Check For Testing.";
if (preg_match("/\bCheck\b/i", $str, $match))
echo "Matched!";
else
echo "not matched";
?>
Example 2: php preg match space or start of string
/\b(stackoverflow)\b/
Example 3: preg_match in php
<?php
$my_text="I Love Regular Expressions";
$my_array = preg_split("/ /", $my_text);
print_r($my_array );
?>
Example 4: preg_match in php
<?php
function_name('/pattern/',subject);
?>
Example 5: 12 hrs for preg match with single and double digit in php
((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))
12:00 pm --------- OK
13:00
1:00 am --------- OK
5:5 am
5:05 PM --------- OK
55:55
09:59
:01
0:59
00:59 PM
Example 6: preg_match in php
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?php echo "Hello, World!";?>
</body>
</html>