Hola
ZayDun. La solución que te traigo podrá no ser la mejor, pero está bastante modularizada y se entiende, así que la podés modificar para que se ajuste a lo que precisás.
No tengo un compilador acá en el trabajo así que no pude probarlo.
Código Delphi
[-]function OnlyNums(Str: String): Boolean;
const
NUMS = [#48 .. #57]; var
I: Integer;
begin
Result := True;
for I := 1 to Length(Str) do
begin
if not(Str[i] IN NUMS) then
begin
Result := False;
Exit;
end,
end;
end;
function OnlyCaps(Str: String): Boolean;
const
CAPS = [#65 .. #90]; var
I: Integer;
begin
Result := True;
for I := 1 to Length(Str) do
begin
if not(Str[i] IN Caps) then
begin
Result := False;
Exit;
end,
end;
end;
function OnlyNumsOrCaps(Str: String): Boolean;
begin
Result := OnlyNums(Str) or OnlyCaps(Str);
end;
procedure ParseStr(MyStr: String);
var
SList: TStringList;
I: Integer;
begin
SList := TStringList.Create;
SList.Delimiter := #32;
SList.DelimitedText := MyStr;
for I := 0 to SList.Count-1 do
if (OnlyNumsOrCaps(SList[i]) and Length(SList[i]) = 5) then
ShowMessage(SList[i]);
end;
Saludos!!