$re = '/(?<txt_pre_linka>\w+)?(?<ceo_link><a .*?>.*?<\/a>)(?<txt_after_linka>.*?)(?=<a .*?>.*?<\/a>|$|\.)/s';
$str = 'ECSE-4530 Digital Signal Processing
Rich Radke, Rensselaer Polytechnic Institute
Lecture 5: the Fourier Transform (9/11/14)
shsdhsh<a class="yt-simple href="/watch?v=5HSn3DPHQcQ&t=2s">0:00:02</a> The Fourier Transform.
Shshshsh<a class="yt-simple" href="/watch?v=5HSn3DPHQcQ&t=219s">0:03:39</a> Thinking ofles of a function
shgshshshs<a class="yt-simple" href="/watch?v=5HSn3DPHQcQ&t=463s">0:07:43</a> Derivim aiod goes to infinity';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php