Ver Mensaje Individual
  #10  
Antiguo 19-04-2012
BrunoBsso BrunoBsso is offline
Miembro
 
Registrado: nov 2009
Ubicación: Berisso, Buenos Aires, Argentina
Posts: 239
Reputación: 15
BrunoBsso Va por buen camino
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]; //'0' .. '9'
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]; //'A' .. 'Z'
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);
//MyStr := 'abc DEF ghi JKL MNÑ oPq RS1 2TUV xzc2 hn2d AJ7J kekgnwo'
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!!
Responder Con Cita