class Regex (View source)

The Regex class holds all methods relating regular expressions.

Properties

static $charClassTextFileVariables The character class to be used within a regex matching all allowed characters for variable names within .txt files.
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 $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(boolean $isVariableSubpattern = false)

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

static string
expression(string $namedReferencePrefix = false)

Return the regex pattern for a single expression.

static string
inPageEditButton()

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

static string
markup()

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

static string
operand(string $namedReferencePrefix = false)

Return the regex to match one operand of an expression.

static string
keyValue()

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

static string
pipe(string $namedReferencePrefix = false, boolean $isVariableSubpattern = false)

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

static string
value(string $subpatternVar)

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

static string
variable(string $namedReferencePrefix = false, string $pipeReference = false)

Return the regex for content variables.

static string
variableKeyGUI()

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

Details

static string csv(boolean $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

boolean $isVariableSubpattern

Return Value

string The regex matching a comma separated parameter string.

static string expression(string $namedReferencePrefix = false)

Return the regex pattern for a single expression.

Valid expressions are:

  • @{var} >= 5
  • @{var} != "Text ..."
  • @{var} = 'Text'
  • not @{var}
  • !@{var}

Parameters

string $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 markup()

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

Return Value

string The markup regex

static string operand(string $namedReferencePrefix = false)

Return the regex to match one operand of an expression.

Valid operands are:

  • @{var}
  • "Text ..."
  • 'Text ...'
  • "Text and @{var}"
  • 5
  • 1.5

Parameters

string $namedReferencePrefix

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 pipe(string $namedReferencePrefix = false, boolean $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 $namedReferencePrefix
boolean $isVariableSubpattern

Return Value

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

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 $namedReferencePrefix = false, string $pipeReference = false)

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 $namedReferencePrefix
string $pipeReference

Return Value

string The regex to match variables.

static string variableKeyGUI()

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

Return Value

string The regex pattern.