Hello everyone,
I am trying to use preg_match for replacing a string.
I am using following code
The preg_replace is not replacing the matching character.
But if i use $regExp = "/[i]/"; instead of $regExp = "/^[i]$/";
it works ,Can I get the reason behind this .I guess the
$regExp = "/^[i]$/"; should also be work.The caret(^) and the dollar($) just specify the start and end of the regular expression.
Thanks
I am trying to use preg_match for replacing a string.
I am using following code
Code:
$regExp = "/^[i]$/"; $match = "hii this"; $result = preg_replace($regExp,"s",$match); echo $result ; // results into hii this
But if i use $regExp = "/[i]/"; instead of $regExp = "/^[i]$/";
it works ,Can I get the reason behind this .I guess the
$regExp = "/^[i]$/"; should also be work.The caret(^) and the dollar($) just specify the start and end of the regular expression.
Thanks
Comment