81
characters in the class. These repetition items will always match the longest possible
sequence;
ter class followed by '-', which also matches 0 or more repetitions of
characters in the class. Unlike '*', these repetition items will always match the shortest
possible sequence;
of a character
in the class;
-th captured
string (see below);
with x, end with y, and where the x and y are balanced. This means that, if one reads the
string from left to right, counting +1 for an x and -1 for a y, the ending y is the first y
where the count reaches 0. For instance, the item %b() matches expressions with
balanced parentheses.
Pattern:
A pattern is a sequence of pattern items. A '^' at the beginning of a pattern anchors the match
at the beginning of the subject string. A '$' at the end of a pattern anchors the match at the end
of the subject string. At other positions, '^' and '$' have no special meaning and represent
themselves.
Captures:
A pattern can contain sub-patterns enclosed in parentheses; they describe captures. When a
match succeeds, the substrings of the subject string that match captures are stored (captured)
for future use. Captures are numbered according to their left parentheses. For instance, in the
pattern "(a*(.)%w(%s*))",the part of the string matching "a*(.)%w(%s*)" is stored as the first
capture (and therefore has number 1);the character matching "." is captured with number 2,
and the part matching "%s*" has number 3.
As a special case, the empty capture () captures the current string position (a number). For
instance, if we apply the pattern "()aa()" on the string "flaaap", there will be two captures: 3
and 5.A pattern cannot contain embedded zeros. Use %z instead.
6.1.21. Input and output functions
io.exists (path)
Checks if given path (file or directory) exists. Return boolean.
io.readfile (file)
Reads whole file at once. Return file contents as a string on success or nil on error.
io.writefile (file, data)
Writes given data to a file. Data can be either a value convertible to string or a table of such
values. When data is a table then each table item is terminated by a new line character. Return
boolean as write result when file can be open for writing or nil when file cannot be accessed.
Example: Write event status to log file located on plugged USB flash drive: