require ('strict')
--
local function main (target) target = target or 'xyz-uvw-rst_res-12345678-1111-2222-3333-012345543210'; -- a test string that I think matches the regex
local part1, part2; if target:find ('_res', 1, true) then part1, part2 = target:match ('([^_]+)(_res.+)'); -- split at constant '_res'; part 2 nil when no constant '_res' else part1 = target; -- part2 not in target end local captures_t = ; -- sequence to hold captures (left to right) if part1:find ('-', 1, true) then -- if part1 has hyphens for capture in part1:gmatch ('(%-%l+)') do table.insert (captures_t, capture); -- add to the captures_t sequence end end if part2 then table.insert (captures_t, part2); -- the part2 capture for capture in part2:gmatch ('%-%x%x%x%x%f[%-]') do table.insert (captures_t, capture); -- add to the captures_t sequence end end return mw.dumpObject (captures_t);end
----------------------------< I S _ V A L I D >--------------------------------------------------------------
local function is_valid (target)
target = target or 'xyz-uvw-rst_res-12345678-1111-2222-3333-012345543210'; -- a test string that I think matches the regex
local part1, part2; if target:find ('_res', 1, true) then part1, part2 = target:match ('([^_]+)(_res.+)'); -- split at constant '_res'; part 2 nil when no constant '_res' else part1 = target; -- part2 not in target end
if part1:find ('[^%-%l]') then -- if
----------------------------< E X P O R T S >----------------------------------------------------------------
return