Optimize regex for template engine

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9284 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-09-22 14:44:25 +00:00
parent c41ca3184a
commit 285a5bd45d

View file

@ -274,11 +274,10 @@
function _parseInline($buff)
{
if(preg_match_all('/<([a-zA-Z0-9]+)[^<>]*?(?:\{[^\{\}]*?\}[^<>]*)*?(?:[ \|]cond| loop)="/s', $buff, $matches) === false) return $buff;
if(preg_match_all('/<([a-zA-Z0-9]+)[^>]*(?:(?:<!--.*?-->|{[^}]*?})[^>]*)*?(?:[ \|]cond| loop)="/s', $buff, $matches) === false) return $buff;
$tags = array_unique($matches[1]);
$tags = implode('|',array_unique($matches[1]));
$split_regex = '@(<(?:/?(?:'.$tags.')|(?:'.$tags.').+?[ "\'])>)@s';
$tags = '(?:'.implode('|',array_unique($matches[1])).')';
$split_regex = '@(<(?:/?'.$tags.'|'.$tags.'.*?["\'/]\s*)>)@s';
$nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE);