From 984d2f36e6f5aedd9cef355a48c0b0d34c4a1a73 Mon Sep 17 00:00:00 2001 From: messju Date: Fri, 16 Apr 2004 08:50:27 +0000 Subject: [PATCH] added explanation for $this->_num_const_regexp --- libs/Smarty_Compiler.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 3a3e6095..163e1432 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -97,6 +97,12 @@ class Smarty_Compiler extends Smarty { // [$bar] $this->_var_bracket_regexp = '\[\$?[\w\.]+\]'; + // matches numerical constants + // 30 + // -12 + // 13.22 + $this->_num_const_regexp = '\-?\d+(?:\.\d+)?'; + // matches $ vars (not objects): // $foo // $foo.bar @@ -105,12 +111,10 @@ class Smarty_Compiler extends Smarty { // $foo[$bar] // $foo[5][blah] // $foo[5].bar[$foobar][4] - $this->_num_const_regexp = '\-?\d+(?:\.\d+)?'; - $this->_dvar_math_regexp = '[\+\-\*\/\%]'; $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]'; $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp - . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:\-?\d+(?:\.\d+)?|' . $this->_dvar_math_var_regexp . ')*)?'; + . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?'; $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp; // matches config vars: