API FindAndReplaceTagsCB

From Vendetta Lua
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"