[DomCrawler] Optimize the regex used to find namespace prefixes

This commit is contained in:
Christophe Coevoet 2015-09-20 23:13:58 +02:00
parent f64cf23811
commit 02818e4c92

View File

@ -1036,13 +1036,13 @@ class Crawler extends \SplObjectStorage
} }
/** /**
* @param $xpath * @param string $xpath
* *
* @return array * @return array
*/ */
private function findNamespacePrefixes($xpath) private function findNamespacePrefixes($xpath)
{ {
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*):[^"\/:]/i', $xpath, $matches)) { if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*+):[^"\/:]/i', $xpath, $matches)) {
return array_unique($matches['prefix']); return array_unique($matches['prefix']);
} }