L3DT users' wiki
Large 3D terrain generator

strfind

Description

Find the position of a substring within a text string.

Function prototype

int strfind <string:Text> <string:TextToFind> <int:StartAt>

Arguments

Name Type Comment
Text string A text string.
TextToFind string A substring, the position of which in Text is to be found.
StartAt int The zero-based starting position in Text to begin looking for TextToFind. Default is 0.

Return value

An integer containing the position of the start of TextToFind in Text. Position indices are zero based.

If TextToFind is not found in Text at or after the position given by StartAt, -1 is returned.

Example

// find the position of "test" in "This is a test" (ans:10)
echo <strfind "This is a test" "test" 0>

… the output of which is written to the event log by echo as:

10

Comments

Case sensitivity

strfind is case sensitive. For a case-insensitive find, use strupper or strlower to convert both the Text and TextToFind arguments to either upper case or lower case.

See also

 
plugins/general/zeoscript/reference/functions/strfind.txt · Last modified: 2017/08/31 04:15 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki