- preg_match: documentation ( source)
<?php
// https://regex101.com/r/dxft9p/1
$string = 'Directed by David Fincher. Written by Jim Uhls. Based on the novel by Chuck Palahniuk.';
$regex = '#Directed by (?<director>\w+\s?\w+). Written by (?<author>\w+\s?\w+)#';
preg_match($regex, $string, $matches);
echo 'Director - '.$matches['director']."\n";
echo 'Author - '.$matches['author'];