« Module:IdentifierRACJ » : différence entre les versions
Modification pour extraire aussi les numéros de dossier qui ont la forme dd-ddd, ddd-ddd et dddd-ddd en plus de dd-ddddddd qui ne sont pas des numéros de décision (cas entre 2000 et 1er juin 2004) |
Nouvelle mouture |
||
| Ligne 4 : | Ligne 4 : | ||
function p.extraireNoDeDecision(frame) | function p.extraireNoDeDecision(frame) | ||
local texte = frame.args[1] or "" | local texte = frame.args[1] or "" | ||
local identifiant = string.match(texte, "(%d%d%-500%d%d%d%d)") | local identifiant = string.match(texte, "(%d%d%-500%d%d%d%d)") | ||
if identifiant then | if identifiant then | ||
return identifiant | return identifiant | ||
end | end | ||
identifiant = string.match(texte, "(%d%d%-%d%d%d%d%d%d%d)") | identifiant = string.match(texte, "(%d%d%-%d%d%d%d%d%d%d)") | ||
return identifiant or "" | return identifiant or "" | ||
end | end | ||
-- | -- Extrait tous les identifiants secondaires valides | ||
function p.extraireNoDeDossier(frame) | function p.extraireNoDeDossier(frame) | ||
local texte = frame.args[1] or "" | local texte = frame.args[1] or "" | ||
| Ligne 23 : | Ligne 18 : | ||
local identifiants = {} | local identifiants = {} | ||
local deja = {} | |||
if decision then | if decision then | ||
deja[decision] = true | deja[decision] = true | ||
-- | -- 1. dd-ddddddd | ||
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)") do | ||
if not deja[id] then | if not deja[id] then | ||
| Ligne 35 : | Ligne 30 : | ||
end | end | ||
end | end | ||
for id in string.gmatch(texte, "(%d%d%-%d%d%d)") do | |||
-- 2. ddd%-ddd (must not be part of longer match) | |||
for id in string.gmatch(texte, "(%f[%d]%d%d%d%-%d%d%d%f[%D])") do | |||
if not deja[id] then | if not deja[id] then | ||
deja[id] = true | deja[id] = true | ||
| Ligne 41 : | Ligne 38 : | ||
end | end | ||
end | end | ||
-- 3. dddd%-ddd | |||
for id in string.gmatch(texte, "(%f[%d]%d%d%d%d%-%d%d%d%f[%D])") do | |||
for id in string.gmatch(texte, "(%d%d%d%d%-%d%d%d)") do | |||
if not deja[id] then | if not deja[id] then | ||
deja[id] = true | deja[id] = true | ||