I have the following code:
<?php
$subject="something";
$pattern="something";
If(preg_match($pattern,$subject)){
echo "Match is found";
}else{
echo "Match is not found";
}
?>
If I have
$subject="apple is fruit and I love apple";
The main point being the string beginning with apple
and ending with apple
Then what should be the pattern so that
match is found
is the output.
I know the pattern can be
"/^apple.*apple$/"
But I don't want to repeat the same word apple.