string.patternMatch

Syntax string.patternMatch (pattern, string)

Params pattern is a character or string of one or more characters to be searched for in string.

string is the string to be searched in an effort to find pattern.

Action Locates the character (s) in pattern in string.

Returns A number indicating the position of pattern in string if found; otherwise, returns 0.

Examples string.patternMatch ("y", "Rudy Kiesler")

   » 4

string.patternMatch ("z", "Rudy Kiesler")

   » 0

t = "1:43";
string.mid (t, string.patternMatch (":", t) + 1, 2);

   » "43"

This extracts characters starting at position found with string.patternMatch and returns "43".

Notes Return value is 1-based (i.e., the first character in a string is 1).

Discuss