Added an example to demonstrate use with patterns
(Use Lua/Libshortcut template. Change category from "LUA Functions" to "Lua functions".) |
(Added an example to demonstrate use with patterns) |
||
| Line 25: | Line 25: | ||
nil | nil | ||
==Example== | |||
Sometimes it's more appropriate to use string.find, rather than string.gmatch, eg: | |||
local msg = "Phase2:- There isn't any need for iterating over this mini-string."; | |||
local startPos, endPos, firstWord, restOfString = string.find( msg, "(%w+)[%s%p]*(.*)"); | |||
==Result== | |||
startPos = 1 | |||
endPos = 66 | |||
firstWord = "Phase2" | |||
restOfString = "There isn't any need for iterating over this mini-string." | |||
{{LUA}} | {{LUA}} | ||