Loading, please wait...

A to Z Full Forms and Acronyms

How to check a case insensitive substring exists within the given string using a regular expression pattern in PHP | PHP program

Feb 28, 2022 PHP, 2495 Views
How to check a case insensitive substring exists within the given string using a regular expression pattern in PHP | PHP program

How to check a case insensitive substring exists within the given string using a regular expression pattern in PHP | PHP program

We will perform regular expression pattern matching using the preg_match() function, here we checked a case insensitive substring exists in the specified string or not.

<?php


$str = "www.tutorialslink.com";
$pattern = "/tutorialslink/i";

$res = preg_match($pattern, $str);

if ($res == 1)
{
    printf("Substring found successfully");
}
else
{
    printf("Substring did not find in the string");
}

?>
A to Z Full Forms and Acronyms