Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Reg Expr (https://www.delphipraxis.net/120975-reg-expr.html)

mohfa 19. Sep 2008 21:59


Reg Expr
 
Hi every body :

I want to search for a Hex Value using a RegExpr.

Let me suppose i have : MyFile.exe that contains the following hex Value :
( 79797979797979795383EC44B823104000B9000000008A1880
C310881883C00183C10181F937D1000075EBA8F0F031F0A9
F0F0F0F07A0870B39E780873B1F173B0F171E9EF17F0F065
DBA8F00030F0ABB3B3B3B37908A8C5CA30F073B0F073B434
EFC0B34BB3D8F5F0F0F0D9FAF0F0F0A9C81731F0D95BA5 )


and in an other text file i store all my match patterns .
ok then let me suppose this match pattern ( stored in this text file ): 5383EC44B823104000B9000000008A1880????A8 this means search for all Hex Values from 53 to A8

that gives me the Result :

5383EC44B823104000B9000000008A1880
C310881883C00183C10181F937D1000075EBA8F0F031F0A9
F0F0F0F07A0870B39E780873B1F173B0F171E9EF17F0F065
DBA8F00030F0ABB3B3B3B37908A8


Is there any way to do it .

Thank you All

s.h.a.r.k 19. Sep 2008 22:07

Re: Reg Expr
 
am i stupid or is there no question?! :gruebel:

Die Muhkuh 19. Sep 2008 22:11

Re: Reg Expr
 
Hi,

you can do this task with Pos and Copy, too. You do not need a reg expr for that.

mohfa 19. Sep 2008 22:11

Re: Reg Expr
 
Zitat:

Zitat von s.h.a.r.k
am i stupid or is there no question?! :gruebel:

No Sir ur'not . Cause i've done some modification .

Sorry Again . :oops:

Die Muhkuh 19. Sep 2008 22:12

Re: Reg Expr
 
Zitat:

Zitat von mohfa
Sorry Again . :oops:

Happens from time to time :zwinker:

s.h.a.r.k 19. Sep 2008 22:17

Re: Reg Expr
 
Zitat:

Zitat von Die Muhkuh
Zitat:

Zitat von mohfa
Sorry Again . :oops:

Happens from time to time :zwinker:

oh yes, it's late, too :spin2:

omata 19. Sep 2008 23:32

Re: Reg Expr
 
Delphi-Quellcode:
procedure GetHexValues(Input:string; Values:TStrings);
var RegExpr:TRegExpr;
begin
  RegExpr:=TRegExpr.Create;
  try
    Values.Clear;
    RegExpr.Expression := '[^A-F0-9]*([A-F0-9]*)[^A-F0-9]*';
    if RegExpr.Exec(Input) then begin
      repeat
        Values.Append(RegExpr.Match[1]);
      until not RegExpr.ExecNext;
    end;
  finally
    RegExpr.free;
  end;
end;
RegExpr

Mackhack 19. Sep 2008 23:52

Re: Reg Expr
 
Zitat:

Zitat von omata
Delphi-Quellcode:
procedure GetHexValues(Input:string; Values:TStrings);
var RegExpr:TRegExpr;
begin
  RegExpr:=TRegExpr.Create;
  try
    Values.Clear;
    RegExpr.Expression := '[^A-F0-9]*([A-F0-9]*)[^A-F0-9]*';
    if RegExpr.Exec(Input) then begin
      repeat
        Values.Append(RegExpr.Match[1]);
      until not RegExpr.ExecNext;
    end;
  finally
    RegExpr.free;
  end;
end;
RegExpr

Omata is our RegExpr expert here. Helped me before, too! :-D 8)

mohfa 20. Sep 2008 22:29

Re: Reg Expr
 
Zitat:

Zitat von omata
Delphi-Quellcode:
procedure GetHexValues(Input:string; Values:TStrings);
var RegExpr:TRegExpr;
begin
  RegExpr:=TRegExpr.Create;
  try
    Values.Clear;
    RegExpr.Expression := '[^A-F0-9]*([A-F0-9]*)[^A-F0-9]*';
    if RegExpr.Exec(Input) then begin
      repeat
        Values.Append(RegExpr.Match[1]);
      until not RegExpr.ExecNext;
    end;
  finally
    RegExpr.free;
  end;
end;
RegExpr

Thank you omata will this RegExp accept the : ???? expression

omata 20. Sep 2008 22:38

Re: Reg Expr
 
Zitat:

Zitat von mohfa
... RegExp accept the : ???? expression

what do you mean with this?

greedy-mode? yes that will be work. another way is RegExpr.ModifierG. see the help-file for RegExpr-Component.


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:54 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz