The best way would be to use an HTML parser, like PHP's DOM.
<?php
$html = <<<HTML
<abbr title="2012-07-16T21:00:00" class="dtstart">Monday, July 16th, 2012</abbr>
HTML;
$dom = new DOMDocument();
$dom->loadHTML($html);
$abbr = $dom->getElementsByTagName("abbr")->item(0);
$title = $abbr->getAttribute("title");
echo $title;
That will work even if your data doesn't look exactly like that:
- If there are other attributes before or after
title
.
- If there are trailing spaces or other invisible characters.
- Regardless of quote type (
"
, '
, or none).
So please, don't use RegEx, as it will eventuall cause you to lose your mind to cuthulu. The <center>
cannot hold it is too late.