jazz icon indicating copy to clipboard operation
jazz copied to clipboard

regex bindings

Open naturallymitchell opened this issue 5 years ago • 5 comments

https://github.com/rust-lang/regex

naturallymitchell avatar Nov 12 '18 04:11 naturallymitchell

@Shazbot needs captures() for lua-module-map.

naturallymitchell avatar Dec 12 '18 23:12 naturallymitchell

Thought I had that in there, but probably was in my other local branch

dariusc93 avatar Dec 13 '18 00:12 dariusc93

actually looks like captures_iter is the one I need:

https://docs.rs/regex/1.1.0/regex/struct.Regex.html#method.captures_iter

Shazbot avatar Dec 13 '18 21:12 Shazbot

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

aleksanderwlodarczyk avatar Jan 03 '19 21:01 aleksanderwlodarczyk

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])

dariusc93 avatar Jan 03 '19 21:01 dariusc93