How to demonstrate the quantifiers in pattern to search a string using a regular expression in PHP | PHP program
Feb 28, 2022
PHP,
1754 Views
How to demonstrate the quantifiers in pattern to search a string using a regular expression in PHP | PHP program
How to demonstrate the quantifiers in pattern to search a string using a regular expression in PHP | PHP program
We will demonstrate the quantifiers in a pattern to search a string using a regular expression, here we will use the preg_replace() function.
<?php
$str = "There are five bananas in the bucket";
$pattern = "/ba(na){2}/i";
if (preg_match($pattern, $str) == 1)
printf("Found");
else
printf("Not Found");
?>