PHP

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

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");
?>

 

TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community