Lore archive · Warcraft Wiki, 2023 dump
Strfindt
Last wiki revision 2010-11-09
strfindt - by Mikk -
A thin wrapper for strfind that returns the results as a table, allowing it to be used in e.g. if clauses while capturing subexpressions.
nBeginPos, nEndPos = <PREFIX>_strfindt(tableCaptures, strHaystack, strRegex, nStartPos, boolPlain)
- (tableCaptures, strHaystack, strRegex, nStartPos, boolPlain)
(identical to strfind after this point)
- tableCaptures : output Table - captured subexpressions
- 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)
- nBegin, nEnd
- nBeginPos : Number - beginning of match (1-based) or nil for no match
- nEndPos: String - end position of match
local results = {}; if(<PREFIX>_strfindt(results, '<b><a href="wowpedia.org">Wowpedia</a>', '<a [^>]*%fhref="([^"]*)"[^>]>([^<])+</a>') then print results[2] . " lives at " . results[1]; end
Wowpedia lives at wowpedia.org
-- 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
Categories
- User defined functions
Source
https://warcraft.wiki.gg/wiki/Strfindt · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.