« Module:IdentifierRACJ » : différence entre les versions
Nouvelle version |
Nouvelle version |
||
| Ligne 5 : | Ligne 5 : | ||
local texte = frame.args[1] or "" | local texte = frame.args[1] or "" | ||
-- 1. | -- 1. Essayer de capturer un identifiant 500xxxx | ||
local identifiant = string.match(texte, "(%f[%d]%d%d%-500%d%d%d%d%f[%D])") | local identifiant = string.match(texte, "(%f[%d]%d%d%-500%d%d%d%d%f[%D])") | ||
if identifiant then | if identifiant then | ||
| Ligne 11 : | Ligne 11 : | ||
end | end | ||
-- 2. | -- 2. Sinon, chercher un identifiant dd-ddddddd NON suivi de -ddd | ||
for id in string.gmatch(texte, " | for id in string.gmatch(texte, "%d%d%-%d%d%d%d%d%d%d") do | ||
local | local startPos, endPos = string.find(texte, id, 1, true) | ||
if startPos then | |||
local suivant = string.sub(texte, endPos + 1, endPos + 4) | |||
if not suivant:match("^%-%d%d%d") then | |||
return id | |||
end | |||
end | end | ||
end | end | ||