<? $match = "/the (car|cat) sat on the (drive|mat)/"; $input = "the cat sat on the mat"; print preg_replace($match, "Matched $0, $1, and $2\n", $input); ?>