Regex
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
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 the regex to match any kind of Automad markup such as variables, toolbox methods, includes, extensions, snippets, loops and conditions.
Return the regex to match one operand of an expression.
Return a regex pattern to match key/value pairs in an invalid JSON string without valid quoting/escaping.
Return the regex for a piped string function or math operation of content variables.
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 (GUI).
Details
at line 101
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.
at line 130
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}
at line 157
static string
inPageEditButton()
Return regex to match any temporary in-page edit button.
at line 170
static string
markup()
Return the regex to match any kind of Automad markup such as variables, toolbox methods, includes, extensions, snippets, loops and conditions.
at line 246
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
at line 272
static string
keyValue()
Return a regex pattern to match key/value pairs in an invalid JSON string without valid quoting/escaping.
at line 299
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.
at line 343
static string
value(string $subpatternVar)
Return the regex to match a single function parameter (pipe).
at line 367
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).
at line 395
static string
variableKeyGUI()
A simplified pattern to match all used variable names in a template (GUI).