Re: [SMARTY] Re: object calls fail after upgrade to 2.6.4
[email protected] (Monte Ohrt)
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <[email protected]> |
Hans_JXrgen_von_Lengerke wrote: > > I saw the regex you're working on and it looks scary. > > Hans The regular expressions can look quite scary, but not so bad if they are kept in digestable chunks. If you take a look at the Smarty_Compiler.class.php you'll see that the regular expressions are all broken down into individual elements, and then used in sequence to match text patterns. For something entertaining, put this at the bottom of the Smarty_Compiler constructor: echo $this->_obj_call_regexp; This is used to match an object call. Here is the regex: (?:(?:\$\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*(?:(?:[\+\*\/\%]|(?:-(?!>)))(?:\-?\d+(?:\.\d+)?|[\$\w\.\+\-\*\/\%\d\>\[\]])*)?(?:\->(?:\$?\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*(?:(?:[\+\*\/\%]|(?:-(?!>)))(?:\-?\d+(?:\.\d+)?|[\$\w\.\+\-\*\/\%\d\>\[\]])*)?))+)(?:\((?:(?:\w+|(?:(?:(?:\$\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*(?:(?:[\+\*\/\%]|(?:-(?!>)))(?:\-?\d+(?:\.\d+)?|[\$\w\.\+\-\*\/\%\d\>\[\]])*)?|\#\w+\#|\%\w+\.\w+\%)|\-?\d+(?:\.\d+)?|(?:"[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*'))(?:\->(?:\$?\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*(?:(?:[\+\*\/\%]|(?:-(?!>)))(?:\-?\d+(?:\.\d+)?|[\$\w\.\+\-\*\/\%\d\>\[\]])*)?)(?:\((?:(?:(?:\$\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*(?:(?:[\+\*\/\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