This function or event no longer exists in version 6.0.2 (19034) of World of Warcraft. Please check the main API page for an up-to-date listing of the valid API functions
Returns information about matches for a pattern in a string. Alias for the standard library function string.find
.
Returns nil
if no matches are found.
See also Lua library functions.
Signature:
start,
end,
...
=
strfind("s",
"pattern"
[,
init
[,
plain]])
Arguments:
s
- A string (string
)pattern
- A regular expression pattern (string
, pattern)init
- Initial position in the strings
at which to begin the search; defaults to 1 if omitted (number
)plain
- True to perform a simple substring search (i.e. consideringpattern
only as a literal string, not a regular expression); false or omitted otherwise (boolean
)
Returns:
start
- Character position ins
at which the first match begins (number
)end
- Character position ins
at which the first match ends (number
)...
- Captured substrings froms
, ifpattern
specifies captures (list
)
Examples:
strfind("Welcome to Azeroth!", "Azeroth") -- returns 12, 18 strfind("|cffffff00|Hquest:982:17|h[Deep Ocean, Vast Sea]|h|r", "quest:(%d+):([-%d]+)|h%[(.-)%]") -- returns 11, 48, "982", "17", "Deep Ocean, Vast Sea"