EasyManua.ls Logo

Canon Camera - Page 118

Canon Camera
257 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5.4 Lua primer 109
%s String
%q Quoted string. The string is formatted so that it can safely be read back
by Lua.
%% %. No argument expected.
i,j = string.find(s1, s2, k)
Searches for the substring s2 in string s1 and returns the indices for the first and the
last character of s2. If s2 is not a substring of s1, the function returns nil. The param-
eter k is optional and may specify the start index for the search.
t,n = string.gsub(s1,s2,s3,k)
Replaces all occurrences of string s2 in string s1 with string s3. Returns the resulting
string and the replacement count. The optional parameter k can limit the number of
replacements.
The functions find() and gsub() accept patterns, too—strings with inter-
spersed control sequences. Most control sequences start with “%” followed
by a character, optionally followed by a modifier character (see below).
These control sequences describe character classes such as “letters” or
digits”.
. All characters
%a Letters
%c Control characters such as new line or form feed
%d Digits
%l Lowercase letters
%p Punctuation characters
%s Whitespace characters
%u Uppercase letters
%w Alphanumeric characters
%x Hexadecimal digits
%z The character “0”
% Escape character. % followed by another character represents the
character itself. Escaping is particularly necessary for the characters
( ) . % + - * ? [ ^ $. For example, “%%” represents “%”.
Using uppercase control characters after the “%” negates the character
class identified by the corresponding lowercase character. For example, %S
stands for anything except white space.
You can define your own character sets by enclosing the characters be-
longing to the set within brackets:
[+–] for example, means ‘+’ or ‘–’.

Table of Contents

Related product manuals