- preg_match: documentation ( source)
<?php
$str = 'abcd,abed,abfd,abgd';
if(preg_match("/ab.d/",$str ,$matches) !== false){ // check any match found or not
echo "match found:".$matches[0]; // when found print that match
}//after printing execution will stops successfully.
?>