jazz
jazz copied to clipboard
regex bindings
https://github.com/rust-lang/regex
@Shazbot needs captures() for lua-module-map.
Thought I had that in there, but probably was in my other local branch
actually looks like captures_iter
is the one I need:
https://docs.rs/regex/1.1.0/regex/struct.Regex.html#method.captures_iter
I've upgraded torchbear from 0.10.4 to 0.10.8 and now 'captures' in regex is nil. I am not sure which exactly version broke it, but when I downgraded to 0.10.4 everything is fine.
EDIT: I just iterated through the keys in pairs(regex):
for k, v in pairs(regex) do log.debug(k) end
in 0.10.4 I got:
22:40:16 DEBUG captures 22:40:16 DEBUG match 22:40:16 DEBUG replace_all 22:40:16 DEBUG captures 22:40:16 DEBUG match 22:40:16 DEBUG replace_all
in 0.10.8 I got:
22:41:21 DEBUG new
So in this version most functions of regex is missing
Regex had a change in one of the updates. To use regex you can use regex.new()
then use the methods such as regex:capture()
eg (from a test)
local regex = regex.new([['([^']+)'\s+\((\d{4})\)]])
local val = "Not my favorite movie: 'Citizen Kane' (1941)"
local result = regex:capture(val):to_table()
print(result[1])