Regular Expressions |
Regular expressions are used to search text using patterns. This section only documents the regular expressions as they are implemented in the GAMSIDE. We do not attempt to explain how regular expressions are used, but the simple examples provide a start.
Syntax for regular expression
<regular expression> ::= <expr> | '^' <expr> | <expr> '$' | '^' <expr> '$'
<expr> ::= <term> | <term> '|' <expr> // Alternation
<term> ::= <factor> | <factor> <term> // Concatenation
<factor> ::= <atom> | <atom> <iterator>
<atom> ::= <char> | '(' <expr> ') | // Sub expression '[' <charclass> ']' | // Character class '[^' <charclass> ']' // Negated character class
<charclass> ::= <charrange> | <charrange><charclass>
<charrange> ::= <ccchar> | <ccchar> '-' <ccchar> // Character range
<char> ::= <any character except meta characters> | '\' <any character at all> | <escape sequence>
<ccchar> ::= <any character except '-' and ']'> | '\' <any character at all>
This syntax implies that parentheses have maximum precedence, followed by square brackets, followed by the closure operators, followed by concatenation, finally followed by alternation.
Meta characters
Escape sequence
Iterator
|