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

static string
csv(bool $isVariableSubpattern = false)

Return a regex to match a sequence of comma separated values or variables.

static string
expression(string|null $namedReferencePrefix = null)

Return the regex pattern for a single expression.

static string
inPageEditButton()

Return regex to match any temporary in-page edit button.

static string
keyValue()

Return a regex pattern to match key/value pairs in an invalid JSON string without valid quoting/escaping.

static string
operand(string|null $namedReferencePrefix = null)

Return the regex to match one operand of an expression.

static string
pipe(string|null $namedReferencePrefix = null, bool $isVariableSubpattern = false)

Return the regex for a piped string function or math operation of content variables.

static string
template()

Return the regex to match any kind of Automad template such as variables, toolbox methods, includes, extensions, snippets, loops and conditions.

static string
value(string $subpatternVar)

Return the regex to match a single function parameter (pipe).

static string
variable(string|null $namedReferencePrefix = null, string|null $pipeReference = null)

Return the regex for content variables.

static string
variableKeyUI()

A simplified pattern to match all used variable names in a template (UI).

Details

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.

Parameters

bool $isVariableSubpattern

Return Value

string The regex matching a comma separated parameter string.

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}

Parameters

string|null $namedReferencePrefix

Return Value

string The regex

static string inPageEditButton()

Return regex to match any temporary in-page edit button.

Return Value

string The regex

static string keyValue()

Return a regex pattern to match key/value pairs in an invalid JSON string without valid quoting/escaping.

Return Value

string The generated pattern.

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

Parameters

string|null $namedReferencePrefix

Return Value

string The regex

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.

Parameters

string|null $namedReferencePrefix
bool $isVariableSubpattern

Return Value

string The regex to match functions and their parameters or math operations

static string template()

Return the regex to match any kind of Automad template such as variables, toolbox methods, includes, extensions, snippets, loops and conditions.

Return Value

string The template regex

static string value(string $subpatternVar)

Return the regex to match a single function parameter (pipe).

Parameters

string $subpatternVar

Return Value

string The regex matching a function parameter.

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).

Parameters

string|null $namedReferencePrefix
string|null $pipeReference

Return Value

string The regex to match variables.

static string variableKeyUI()

A simplified pattern to match all used variable names in a template (UI).

Return Value

string The regex pattern.