Ver Mensaje Individual
  #5  
Antiguo 15-09-2014
Avatar de n3mohack
n3mohack n3mohack is offline
Miembro
 
Registrado: may 2004
Ubicación: Chile-Stgo-Huechuraba
Posts: 41
Reputación: 0
n3mohack Va por buen camino
Cita:
Empezado por nlsgarcia Ver Mensaje
n3mohack,







Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RegExpr;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// Busca fechas en el formato dd/mm/yyyy por medio de expresiones regulares
procedure TForm1.Button1Click(Sender: TObject);
var
   RE : TRegExpr;
   ArrayDates : Array[0..5] of String;
   i : Integer;
   MsgApp : String;
   MaskDate : String;

begin

   MaskDate := '99/99/9999';

   ArrayDates[0] := '01/07/2014';
   ArrayDates[1] := '01/07/14';
   ArrayDates[2] := '1/7/14';
   ArrayDates[3] := '01/07/2014 es la fecha de prueba';
   ArrayDates[4] := 'La fecha 01/07/2014 es la fecha de prueba';
   ArrayDates[5] := 'La fecha de prueba es 01/07/2014';

   RE := TRegExpr.Create;

   RE.Expression := '[[0-9]{2}/[0-9]{2}/[0-9]{4}';

   for i := Low(ArrayDates) to High(ArrayDates) do
   begin
      if RE.Exec(ArrayDates[i]) then
      begin
         MsgApp := Format('Formato de Fecha %s Encontrado en : %s',[MaskDate,ArrayDates[i]]);
         MessageDlg(MsgApp,mtInformation,[mbOK],0);
      end
      else
      begin
         MsgApp := Format('No encontrado Formato de Fecha %s en : %s',[MaskDate,ArrayDates[i]]);
         MessageDlg(MsgApp,mtInformation,[mbOK],0);
      end;

   end;

   RE.Free;

end;

end.
El código anterior en Delphi 7 bajo Windows 7 Professional x32, permite buscar fechas con el formato 'dd/mm/yyyy' en un string por medio de expresiones regulares, a través de la librería : TRegExpr - Freeware Delphi Regular Expressions Library.

La librería TRegExpr - Freeware Delphi Regular Expressions Library (Español e Ingles) esta disponible en : TRegExpr - Delphi Regular Expressions Library.rar

Nota: Para usar la librería solo se debe incluir la ruta de sus unidades en : Tools->Environment Options->Library->Library path.

Revisa esta información:


Espero sea útil

Nelson.
Muchas gracias lo voy a revisar...
__________________
Si es Chileno.. es bueno.
Responder Con Cita