<?php $str = "I bought _ sheep"; preg_match("/I bought (.*?) sheep/", $str, $match); print_r($match); ?>