= 5 * - @{var} != "Text ..." * - @{var} = 'Text' * - not @{var} * - !@{var} * * @param string|null $namedReferencePrefix * @return string The regex */ public static function expression(?string $namedReferencePrefix = null): string { if ($namedReferencePrefix) { $left = $namedReferencePrefix . 'Left'; $operator = '?P<' . $namedReferencePrefix . 'Operator>'; $right = $namedReferencePrefix . 'Right'; $not = '?P<' . $namedReferencePrefix . 'Not>'; $var = '?P<' . $namedReferencePrefix . 'Var>'; } else { $left = ''; $operator = '?:'; $right = ''; $not = '?:'; $var = '?:'; } return '(?:' . self::operand($left) . '\s*(' . $operator . '!?=|>=?|<=?)\s*' . self::operand($right) . '|(' . $not . '!|not\s+)?(' . $var . self::variable() . '))'; } /** * Return regex to match any temporary in-page edit button. * * @return string The regex */ public static function inPageEditButton(): string { return preg_quote(Delimiters::INPAGE_BUTTON_OPEN) . '.+?' . preg_quote(Delimiters::INPAGE_BUTTON_CLOSE); } /** * Return a regex pattern to match key/value pairs in an invalid JSON string * without valid quoting/escaping. * * @return string The generated pattern. */ public static function keyValue(): string { $key = '(?P' . self::CHAR_CLASS_ALL_VARS . '+|\"' . self::CHAR_CLASS_ALL_VARS . '+\")'; $value = '(?P' . self::value(self::variable()) . ')'; $pair = '\s*' . $key . '\s*:\s*' . $value . '\s*'; return '(?<=(\{|,))(' . $pair . ')(?=(\}|,))'; } /** * Return the regex to match one operand of an expression. * * Valid operands are: * * - @{var} * - "Text ..." * - 'Text ...' * - "Text and @{var}" * - 5 * - 1.5 * * @param string|null $namedReferencePrefix * @return string The regex */ public static function operand(?string $namedReferencePrefix = null): string { if ($namedReferencePrefix) { $doubleQuoted = '?P<' . $namedReferencePrefix . 'DoubleQuoted>'; $singleQuoted = '?P<' . $namedReferencePrefix . 'SingleQuoted>'; $num = '?P<' . $namedReferencePrefix . 'Number>'; $var = '?P<' . $namedReferencePrefix . 'Var>'; } else { $doubleQuoted = '?:'; $singleQuoted = '?:'; $num = '?:'; $var = '?:'; } return '(?:"(' . $doubleQuoted . '(?:[^"\\\\]|\\\\.)*)"|\'(' . $singleQuoted . '(?:[^\'\\\\]|\\\\.)*)\'|(' . $num . self::NUMBER . ')|(' . $var . self::variable() . '))'; } /** * Return the regex for a piped string function or math operation of content variables. * Like: * - "| name (parameters)" * - "| +5" * * Parameters can be strings wrapped in quotes, * single words without quotes, numbers and variables. * In case $isVariableSubpattern is true, relative references to the wrapping * variable pattern are used to match variables. * * @param string|null $namedReferencePrefix * @param bool $isVariableSubpattern * @return string The regex to match functions and their parameters or math operations */ public static function pipe(?string $namedReferencePrefix = null, bool $isVariableSubpattern = false): string { if ($namedReferencePrefix) { $function = '?P<' . $namedReferencePrefix . 'Function>'; $parameters = '?P<' . $namedReferencePrefix . 'Parameters>'; $operator = '?P<' . $namedReferencePrefix . 'Operator>'; $num = '?P<' . $namedReferencePrefix . 'Number>'; } else { $function = ''; $parameters = ''; $operator = ''; $num = ''; } if ($isVariableSubpattern) { $subpatternMathVar = '(?-10)'; } else { $subpatternMathVar = self::variable(null, '(?R)'); } return '\|(' . // Function name. '\s*(' . $function . '[\w][\w\/\-]*)\s*' . // Parameters. '(?:\(' . '(' . $parameters . self::csv($isVariableSubpattern) . ')?' . '\)\s*)?' . '|' . // Math. '\s*(' . $operator . '[\+\-\*\/])\s*(' . $num . self::NUMBER . '|' . $subpatternMathVar . ')\s*' . ')'; } /** * Return the regex to match any kind of Automad template such as variables, * toolbox methods, includes, extensions, snippets, loops and conditions. * * @return string The template regex */ public static function template(): string { $statementPatterns = array(); foreach (FeatureProvider::getProcessorClasses() as $cls) { $statementPatterns[] = $cls::syntaxPattern(); } return '(' . '(?P' . PatternAssembly::variable() . ')|' . implode('|', $statementPatterns) . ')'; } /** * Return the regex to match a single function parameter (pipe). * * @param string $subpatternVar * @return string The regex matching a function parameter. */ public static function value(string $subpatternVar): string { $string = '"(?:[^"\\\\]|\\\\.)*+"|\'(?:[^\'\\\\]|\\\\.)*+\''; return '\s*(' . $string . '|\w+|' . self::NUMBER . '|' . $subpatternVar . ')\s*'; } /** * Return the regex for content variables. * A prefix can be defined as the first parameter to create named backreferences for each capturing group. * Like: @{var|function1(...)|function2(...)| ... } * * In case the pattern is used as a subpattern of the pipe() method, $pipeReference can be specified to * reference the whole pipe pattern by using a relative reference or (?R). * * @param string|null $namedReferencePrefix * @param string|null $pipeReference * @return string The regex to match variables. */ public static function variable(?string $namedReferencePrefix = null, ?string $pipeReference = null): string { if ($namedReferencePrefix) { $name = '?P<' . $namedReferencePrefix . 'Name>'; $functions = '?P<' . $namedReferencePrefix . 'Functions>'; } else { $name = ''; $functions = ''; } if (!$pipeReference) { $pipeReference = self::pipe(null, true); } return '(' . preg_quote(Delimiters::VAR_OPEN) . '\s*(' . $name . self::CHAR_CLASS_ALL_VARS . '+)\s*' . '(' . $functions . '(?:' . $pipeReference . ')*)' . preg_quote(Delimiters::VAR_CLOSE) . ')'; } /** * A simplified pattern to match all used variable names in a template (UI). * * @return string The regex pattern. */ public static function variableKeyUI(): string { return preg_quote(Delimiters::VAR_OPEN) . '\s*(?P' . self::CHAR_CLASS_EDITABLE_VARS . '+)'; } } __halt_compiler();----SIGNATURE:----DNIACi0uPPengfNRA8M5WVROKrILwG4wQtVIsSLcnh4TRQFpkdok90lnYm6j1Lq9PtcU3Qx2k2O1+KgpEKEJ6FwA959DRnk7NCIF5fyaGGu6TSKnAA8yFOtQ07LfU/1OzTdFQ3rmyG35xLyej1cfe3EFE2VxsQBaZrpuwEBELOlY3UPrf88344pn4BGYYjt9tXHw25IOM39x+eQgnA7mFdYG50gZgNPZce2lUPHZ4I4/YJqm5NFoHL2HcoY45ZAMRR7/7W6ii5BfBPuKWFbjDuJYzlXMF+IL5zxt8OT1vfJC9ku0MzWelY9UYqbax+Yv7h0STXqomAbupo8mqEGSmhCZ4tkMHHcX1kKGQoaYbIgFpe8uJiGNM++y9CN007kUHIDZleKPrTnaSLpACzokSrGea8zkHgvL+POwXkCqwN03Z8VtWUHTqGOc+n8FtzlFarQvm5YiwG6rTsBSortg4ZZ9i0Ud7RcCH5zBSm6aSakCa3ydi4bBfw8PHY4BsuLeftwg/UVn3jwSIoGiNhiOQvJD5Ab2xQeDAyh9+jWRlEQBn4BMNAHEmABo3uE3IhGchgEW8/VE3EoCGctOy2Dzmq0CPQf/xXkVaHj587LX1+q4Ya/MVlL9rp9RilCHH6iKQAI0FfK/48F3S013DSNi1lOBDIHbrKWXb2u5lNlVyNw=----ATTACHMENT:----NjMyMTcwOTc1ODg3NzA4MyA3NjYxODg2MjUyNzk4NTM4IDc1NjcxMDY0MzYwODAzNjM=