Quantcast
Download
(20 Kb)
Download
Updated: 01/08/19 09:23 PM
Compatibility:
Murkmire (4.2)
Updated:01/08/19 09:23 PM
Created:01/08/19 09:23 PM
Monthly downloads:1,242
Total downloads:3,565
Favorites:0
MD5:
LibLuLpeg
Version: a10d246
by: Coorbin [More]
This is the LuLPeg library from https://github.com/pygy/LuLPeg but it has been gently hacked on to work with the Lua engine of ESO. The version of upstream LuLPeg is from commit ID a10d246 on November 22, 2018.

Here is a sample function using the 're' module, which provides a regex engine (see syntax here: http://www.inf.puc-rio.br/~roberto/lpeg/re.html ) -- this compiles and runs correctly in ESO.

Code:
local function do_regex() 
  local re = LibStub("LibLuLpeg").lib.re
  -- find the position of the first numeral in a string
  d(re.find("the number 423 is odd", "[0-9]+"))  --> 12    14

  -- returns all words in a string
  d(re.match("the number 423 is odd", "({%a+} / .)*"))
  -- > the    number    is    odd

  -- returns the first numeral in a string
  d(re.match("the number 423 is odd", "s <- {%d+} / . s"))
  -- > 423

  d(re.gsub("hello World", "[aeiou]", "."))
  -- > h.ll. W.rld
end
So, you can use either the RegEx-like engine of the "re" module (it isn't compliant with PCRE or anything but it's almost as expressive), or you can use LPEG, which is really flexible but a weird syntax.
Optional Files (0)


There have been no comments posted to this file.
Be the first to add one.



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.