API FindAndReplaceTagsCB

From Vendetta Lua
Revision as of 21:58, 25 January 2009 by Chefkoch (Talk | contribs) (split)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

FindAndReplaceTagsCB

Definition:
FindAndReplaceTagsCB(string text, function cb) -> string ret1
Description:
Pass each occurances of with < and > enclosed substrings in text to cb and replace them with the return value
Arguments:
test string to replace tags in
cb called with the content of each tag as argument
Returns:
ret1: converted text
Example:

local function find_cb(t)
      if t == "br" then
      	 return "\n"
      end
end
FindAndReplaceTags("hi this is a<br>linebreak", find_cb)<br>
-> "hi this is a
linebreak"