');
$html = preg_replace('/\son\w+\s*=\s*("[^"]*"|\'[^\']*\'|[^\s>]+)/i', '', $html) ?? '';
$html = preg_replace_callback('/]*)>/i', function (array $matches) {
$attrs = $matches[1];
if (! preg_match('/href\s*=\s*("|\')(https?:\/\/[^"\']+)\1/i', $attrs, $href)) {
return '';
}
return '';
}, $html) ?? '';
return $html;
}
}