« Module:IdentifierRACJ » : différence entre les versions
Aller à la navigation
Aller à la recherche
Nouvelle mouture |
Nouvelle mouture |
||
| Ligne 13 : | Ligne 13 : | ||
function p.extraireNoDeDossier(frame) | function p.extraireNoDeDossier(frame) | ||
local texte = frame.args[1] or "" | local texte = frame.args[1] or "" | ||
local decision = | |||
-- Extraire le premier identifiant, qu'il soit 500xxxx ou non | |||
local decision = p.extraireNoDeDecision{ args = { texte } } | |||
if decision == "" then return "" end | |||
local deja = {} | local deja = {} | ||
local prefixesExclus = {} | local prefixesExclus = {} | ||
local identifiants = {} | local identifiants = {} | ||
deja[decision] = true | |||
-- 1. dd-ddddddd-ddd | |||
for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d%-%d%d%d)") do | |||
if not deja[id] then | |||
deja[id] = true | |||
prefixesExclus[string.match(id, "^(%d%d%-%d%d%d%d%d%d%d)")] = true | |||
table.insert(identifiants, id) | |||
end | end | ||
end | |||
-- 2. dd-ddddddd (sauf si déjà inclus comme préfixe) | |||
for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d)") do | |||
if not deja[id] and not prefixesExclus[id] then | |||
deja[id] = true | |||
table.insert(identifiants, id) | |||
end | end | ||
end | |||
-- 3. ddd-ddd | |||
for id in string.gmatch(texte, "(%f[%d]%d%d%d%-%d%d%d%f[%D])") do | |||
if not deja[id] then | |||
deja[id] = true | |||
table.insert(identifiants, id) | |||
end | end | ||
end | |||
-- 4. dddd-ddd | |||
for id in string.gmatch(texte, "(%f[%d]%d%d%d%d%-%d%d%d%f[%D])") do | |||
if not deja[id] then | |||
deja[id] = true | |||
table.insert(identifiants, id) | |||
end | end | ||
end | end | ||
Version du 2 juin 2025 à 18:41
local p = {}
function p.extraireNoDeDecision(frame)
local texte = frame.args[1] or ""
local identifiant = string.match(texte, "(%d%d%-500%d%d%d%d)")
if identifiant then
return identifiant
end
identifiant = string.match(texte, "(%d%d%-%d%d%d%d%d%d%d)")
return identifiant or ""
end
function p.extraireNoDeDossier(frame)
local texte = frame.args[1] or ""
-- Extraire le premier identifiant, qu'il soit 500xxxx ou non
local decision = p.extraireNoDeDecision{ args = { texte } }
if decision == "" then return "" end
local deja = {}
local prefixesExclus = {}
local identifiants = {}
deja[decision] = true
-- 1. dd-ddddddd-ddd
for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d%-%d%d%d)") do
if not deja[id] then
deja[id] = true
prefixesExclus[string.match(id, "^(%d%d%-%d%d%d%d%d%d%d)")] = true
table.insert(identifiants, id)
end
end
-- 2. dd-ddddddd (sauf si déjà inclus comme préfixe)
for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d)") do
if not deja[id] and not prefixesExclus[id] then
deja[id] = true
table.insert(identifiants, id)
end
end
-- 3. ddd-ddd
for id in string.gmatch(texte, "(%f[%d]%d%d%d%-%d%d%d%f[%D])") do
if not deja[id] then
deja[id] = true
table.insert(identifiants, id)
end
end
-- 4. dddd-ddd
for id in string.gmatch(texte, "(%f[%d]%d%d%d%d%-%d%d%d%f[%D])") do
if not deja[id] then
deja[id] = true
table.insert(identifiants, id)
end
end
return table.concat(identifiants, ", ")
end
return p