Module:IdentifierRACJ

Version datée du 1 juin 2025 à 11:58 par Marc (discussion | contributions) (Ajout d'une fonction pour extraire le numéro de dossier)

local p = {}

-- Extrait un identifiant de la forme : 2 chiffres - 7 chiffres (ex: 40-0009775)
function p.extraireNoDeDecision(frame)
    local texte = frame.args[1] or ""
    local identifiant = string.match(texte, "(%d%d%-%d%d%d%d%d%d%d)")
    return identifiant or ""
end

-- Extrait un identifiant de la forme : 2 chiffres - 7 chiffres - 3 chiffres (ex: 40-0733535-004)
function p.extraireNoDeDossier(frame)
    local texte = frame.args[1] or ""
    local identifiant = string.match(texte, "%d%d%-%d%d%d%d%d%d%d%-(%d%d%d)")
    if identifiant then
        -- Retourne le bloc complet incluant le préfixe
        return string.match(texte, "(%d%d%-%d%d%d%d%d%d%d%-%d%d%d)")
    else
        return ""
    end
end

return p