« Module:IdentifierRACJ » : différence entre les versions
Aller à la navigation
Aller à la recherche
Nouvelle mouture qui conserve les numéros de dossier qui ont la forme dd-ddddddd-ddd |
Nouvelle mouture |
||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
function p.extraireNoDeDecision(frame) | function p.extraireNoDeDecision(frame) | ||
local texte = frame.args[1] or "" | local texte = frame.args[1] or "" | ||
| Ligne 12 : | Ligne 11 : | ||
end | end | ||
function p.extraireNoDeDossier(frame) | function p.extraireNoDeDossier(frame) | ||
local texte = frame.args[1] or "" | local texte = frame.args[1] or "" | ||
local decision = string.match(texte, "(%d%d%-500%d%d%d%d)") | local decision = string.match(texte, "(%d%d%-500%d%d%d%d)") | ||
local deja = {} | local deja = {} | ||
local prefixesExclus = {} | |||
local identifiants = {} | local identifiants = {} | ||
| Ligne 23 : | Ligne 21 : | ||
deja[decision] = true | deja[decision] = true | ||
-- 1. dd-ddddddd | -- 1. dd-ddddddd-ddd (complet) | ||
for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d)") do | for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d%-%d%d%d)") do | ||
if not deja[id] then | if not deja[id] then | ||
deja[id] = true | deja[id] = true | ||
prefixesExclus[string.match(id, "^(%d%d%-%d%d%d%d%d%d%d)")] = true | |||
table.insert(identifiants, id) | table.insert(identifiants, id) | ||
end | end | ||
end | end | ||
-- 2. dd-ddddddd | -- 2. dd-ddddddd (exclure ceux déjà utilisés comme préfixes) | ||
for id in string.gmatch(texte, "(%d%d%-%d%d%d%d | for id in string.gmatch(texte, "(%d%d%-%d%d%d%d%d%d%d)") do | ||
if not deja[id] then | if not deja[id] and not prefixesExclus[id] then | ||
deja[id] = true | deja[id] = true | ||
table.insert(identifiants, id) | table.insert(identifiants, id) | ||
Version du 2 juin 2025 à 18:12
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 ""
local decision = string.match(texte, "(%d%d%-500%d%d%d%d)")
local deja = {}
local prefixesExclus = {}
local identifiants = {}
if decision then
deja[decision] = true
-- 1. dd-ddddddd-ddd (complet)
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 (exclure ceux déjà utilisés comme préfixes)
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
end
return table.concat(identifiants, ", ")
end
return p