PatternAssembly
class PatternAssembly (View source)
The PatternAssembly class contains all methods to assemble regular expressions patterns.
Properties
static | $charClassAllVariables | The character class to be used within a regex matching all allowed characters for all kine of variable names (content in .txt files, system variables ( :var ) and query string items ( ?var )). | |
static | $charClassTextFileVariables | The character class to be used within a regex matching all allowed characters for variable names within .txt files. | |
static | $logicalOperator | Logical operand "and" or "or". | |
static | $number | Number (integer and float). | |
static | $outerStatementMarker | The outer statement marker helps to distinguish all outer wrapping statements from the inner statements. |
Methods
Return a regex to match a sequence of comma separated values or variables.
Return the regex pattern for a single expression.
Return regex to match any temporary in-page edit button.
Return a regex pattern to match key/value pairs in an invalid JSON string without valid quoting/escaping.
Return the regex to match one operand of an expression.
Return the regex for a piped string function or math operation of content variables.
Return the regex to match any kind of Automad template such as variables, toolbox methods, includes, extensions, snippets, loops and conditions.
Return the regex to match a single function parameter (pipe).
Return the regex for content variables.
A simplified pattern to match all used variable names in a template (UI).
Details
at line 84
static string
csv(bool $isVariableSubpattern = false)
Return a regex to match a sequence of comma separated values or variables.
In case $isVariableSubpattern is true, the generated value patterns have a relative reference to the wrapping main variable pattern to match variables within parameters.
at line 109
static string
expression(string|null $namedReferencePrefix = null)
Return the regex pattern for a single expression.
Valid expressions are:
- @{var} >= 5
- @{var} != "Text ..."
- @{var} = 'Text'
- not @{var}
- !@{var}
at line 132
static string
inPageEditButton()
Return regex to match any temporary in-page edit button.
at line 142
static string
keyValue()
Return a regex pattern to match key/value pairs in an invalid JSON string without valid quoting/escaping.
at line 165
static string
operand(string|null $namedReferencePrefix = null)
Return the regex to match one operand of an expression.
Valid operands are:
- @{var}
- "Text ..."
- 'Text ...'
- "Text and @{var}"
- 5
- 1.5
at line 196
static string
pipe(string|null $namedReferencePrefix = null, bool $isVariableSubpattern = false)
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.
at line 236
static string
template()
Return the regex to match any kind of Automad template such as variables, toolbox methods, includes, extensions, snippets, loops and conditions.
at line 255
static string
value(string $subpatternVar)
Return the regex to match a single function parameter (pipe).
at line 275
static string
variable(string|null $namedReferencePrefix = null, string|null $pipeReference = null)
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).
at line 299
static string
variableKeyUI()
A simplified pattern to match all used variable names in a template (UI).