PHP program to demonstrate the regular expression to replace the substring within the string
<?php
//PHP program to demonstrate the regular expression
//to replace the substring within the string.
$str = "Welcome to India";
$pattern = "/india/i";
$str1 = preg_replace($pattern, "USA", $str);
print ($str1);
?>
Output
Welcome to USA
