Loading, please wait...

A to Z Full Forms and Acronyms

How to demonstrate the quantifiers in pattern to search a string using a regular expression in PHP | PHP program

Feb 28, 2022 PHP, 1380 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");
?>

 

A to Z Full Forms and Acronyms