Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:USERAPI strfindt
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{userfunc}} <!-- Leave this line in! --> <center>'''strfindt''' ''- by [[user:Mikk|Mikk]] -''</center> <!-- Describe the purpose of the function(s), exhausting detail can be saved for a later section --> A thin wrapper for [[API strfind|strfind]] that returns the results as a table, allowing it to be used in e.g. if() clauses while capturing subexpressions. <!-- List return values and arguments as well as function name(s), follow Blizzard usage convention for args --> nBeginPos, nEndPos = ''<PREFIX>''_strfindt(tableCaptures, strHaystack, strRegex, nStartPos, boolPlain) == Function Parameters == <!-- If you are listing several functions, you'll need to have several of these, e.g. "Foo Parameters", "Bar Parameters",... --> === Arguments === <!-- List each argument, together with its type --> :(tableCaptures, strHaystack, strRegex, nStartPos, boolPlain) :;tableCaptures : '''output''' Table - captured subexpressions <small>(identical to [[API strfind|strfind]]() after this point)</small> :;strHaystack : String - the string to perform the search in :;strRegex : String - the regular expression (search pattern) :;nStartPos : Number - the position to begin the search on (nil = from the beginning) :;boolPlain : Boolean - set to ''true'' to not use regexes (which defeats the whole purpose of this wrapper) === Returns === <!-- List each return value, together with its type --> :nBegin, nEnd :;nBeginPos : Number - beginning of match (1-based) or nil for no match :;nEndPos: String - end position of match == Example == local results = {}; if(''<PREFIX>''_strfindt(results, '<b><a href="wowwiki.com">WoWWiki</a>', '<a [^>]*%fhref="([^"]*)"[^>]>([^<])+</a>') then print results[2] . " lives at " . results[1]; end ====Result==== WoWWiki lives at wowwiki.com ==Code== -- Returns: nBeginPos, nEndPos. Captured expressions go in tOut function ''<PREFIX>''_strfindt(tOut, strFind, strRegex, nStart, bPlain) local a = { string.find(strFind, strRegex, nStart, bPlain) }; while(getn(tOut)>0) do tremove(tOut,1); end for _,v in a do tinsert(tOut, v); end return a[1], a[2]; end __NOTOC__ [[Category:User defined functions]]
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Apinav
(
edit
)
Template:Editlink
(
edit
)
Template:Notebox
(
edit
)
Template:Userfunc
(
edit
)