Chapter 18 String Functions

Table of Contents
18.1 Searching into Strings
18.2 Substrings
18.3 Replacing and Inserting
18.4 Tokenizing
18.5 Trimming
18.6 Changing Case
18.7 Template strings
18.8 Examples

18.1 Searching into Strings

18.1.1 find

Note: Added in G-Cows version 1.2

Synopsis

find(string, substring);

find(string, substring, from);

Description

The find function searches string for a specified substring (possibly a single character) and returns its starting position. You can supply the third parameter from to specify the character where search must begin.

If substring is not found find returns -1.

18.1.2 rfind

Note: Added in G-Cows version 1.2

Synopsis

rfind(string, substring);

rfind(string, substring, from);

Description

The rfind function searches from end to beginning string for a specified substring (possibly a single character) and returns its starting position. You can supply the third parameter from to specify the character where search must begin.

If substring is not found rfind returns -1.

18.1.3 findfirstof

Note: Added in G-Cows version 1.2

Synopsis

findfirstof(string, chars);

Description

findfirstof searches string for the first match of any character stored in chars and returns its position.

If no match is found returns -1.

18.1.4 findlastof

Note: Added in G-Cows version 1.2

Synopsis

findlastof(string, chars);

Description

findlastof searches string for the last match of any character stored in chars and returns its position.

If no match is found returns -1.

18.1.5 findfirstnotof

Note: Added in G-Cows version 1.2

Synopsis

findfirstnotof(string, chars);

Description

findfirstnotof searches the first element of string that doesn't match any character stored in chars and returns its position.

If no match is found returns -1.

18.1.6 findlastnotof

Note: Added in G-Cows version 1.2

Synopsis

findlastnotof(string, chars);

Description

findlastnotof searches the last element of string that doesn't match any character stored in chars and returns its position.

If no match is found returns -1.

18.1.7 char

Note: Added in G-Cows version 1.2

Synopsis

char(string, index);

Description

The char function extracts from string the character located at position index.

18.1.8 startswith

Note: Added in G-Cows version 1.2

Synopsis

startswith(string, prefix);

Description

Returns true if string starts with prefix. Otherwise returns false.

18.1.9 endswith

Note: Added in G-Cows version 1.2

Synopsis

endswith(string, suffix);

Description

Returns true if string ends with suffix. Otherwise returns false.

This manual can be downloaded from http://www.g-cows.org/.