- preg_match: documentation ( source)
<?php
$html = '<meta name="generator" content="WordPress 4.8.2">';
$dom = new DOMDocument;
$dom->loadHTML($html);
$heads = $dom->getElementsByTagName('meta');
foreach ($heads as $head) {
if($head->getAttribute('name') == 'generator' && preg_match('/wordpress (?<version>(?:\d+\.?)+)/i', $head->getAttribute('content'), $version)) {
die($version['version']);
}
}