Canon Camera Hackers Manual page 118

Camera hackers manual berthold daum
Table of Contents

Advertisement

%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
Lowercase letters
%l
Punctuation characters
%p
Whitespace characters
%s
%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 '–'.
109
5.4 Lua primer

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents