Как насчет этого
$str = '<div id="btn-loc" class="hidden" attrLoc="1">';
$pattern = '/<div id="btn-loc".*\sattrLoc="([0-9])">/';
preg_match($pattern, $str, $matches);
var_dump($matches);
Выходы
array
0 => string '<div id="btn-loc" class="hidden" attrLoc="1">' (length=45)
1 => string '1' (length=1)