Link Search Menu Expand Document

find

Explanation The target character string is searched from the start position of the character string, and the start position of the matching part is obtained. The position is 0 at the beginning of the string.
Call format var i = find ( string, target string, start position [, processing unit ])
Return value The beginning position of the matched part
Arguments String string Character string to search
String target string Character string to be searched
Integer start position The position to start the search in the target character string
Integer processing unit 0: Treat as one character without distinguishing between half-width and full-width
1: Half-width characters are treated as one character, and full-width characters are treated as two characters. If omitted, half-width and full-width characters will not be distinguished.
*AI does not distinguish between half-width and full-width characters regardless of the argument*
Exception None
Example of use
var str = "I have a book. I have a pen.";
var i = -1;
while (true) {
    i = find(str, "have", i + 1);
    if (i < 0) {
        break;
    }
    print(i, "\n");
}
Related item