WoW:API strfind: Difference between revisions
Jump to navigation
Jump to search
m
added pattern tutorial link
No edit summary |
m (added pattern tutorial link) |
||
| Line 1: | Line 1: | ||
string.find(s, pattern [, init [, plain]]) | string.find(s, pattern [, init [, plain]]) | ||
Find the first | Find the first occurrence of the pattern in the string passed. If an instance of the pattern is found a pair of values representing the start and end of the string is returned. If the pattern cannot be found nil is returned. | ||
> = string.find("Hello Lua user", "Lua") | > = string.find("Hello Lua user", "Lua") | ||
| Line 17: | Line 17: | ||
13 13 | 13 13 | ||
The pattern argument can be a regular expression which allows more complex searchs. See the PatternsTutorial for more information. We can turn off the regular expression feature by using the optional fourth argument plain. plain takes a boolean value and must be preceeded by init. E.g., | The pattern argument can be a regular expression which allows more complex searchs. See the [http://lua-users.org/wiki/PatternsTutorial Patterns Tutorial on Lua-Users.org] for more information. We can turn off the regular expression feature by using the optional fourth argument plain. plain takes a boolean value and must be preceeded by init. E.g., | ||
> = string.find("Hello Lua user", "%su") -- find a space character followed by "u" | > = string.find("Hello Lua user", "%su") -- find a space character followed by "u" | ||
| Line 23: | Line 23: | ||
> = string.find("Hello Lua user", "%su", 1, true) -- turn on plain searches, now not found | > = string.find("Hello Lua user", "%su", 1, true) -- turn on plain searches, now not found | ||
nil | nil | ||
---- | ---- | ||
{{WoW API}} | {{WoW API}} | ||