Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Для новичков > Search using Regexpr


Автор: randy 3.11.2008, 12:17
Hi every body , i want to use the Regexpr with the FastStrings unit , especially the FastPos function :
Код

function FastPos(const aSourceString, aFindString : string; const aSourceLen, aFindLen, StartPos : Integer) : Integer; 


As an example : 
i 've this Hex Value: C3??881883C00 
This will match : C310881883C00 or C300881883C00 that means ?? will match any value between C3 and 88 

Or please simply how to use the Delphi Pos with the RegExpr with the above example , i think i must use the RegExpr.ModifierG


many thanks 

Автор: randy 4.11.2008, 12:55
Let me suppose the following :
Var
S:String;
.
S:='FF????????92C92FF10000*558BEC81FFD8060000535657????????????????????8A??80????88??83??0183??0181F99005000075EB'

so what i want is that the S value will be found in the following text :
C310881883C00183C10181F937D1000075EBA8F0F031F0A9F0F0F0F07A0870B39E780873B1F173
B0F171E9EF17F0F065FF030F0ABB92C92FF10000EFC0B34BB3D8F558BEC81FFD80600005356574000
B9000000008A18808AFF80000088A883A80183000181F99005000075EB
EFC0B34BB3D8F5F0F0F0D9FA
F0F0F0A9C81731F0D95BA5

i've tried using TRegExpr in this way :
Код

function RegPos(const Expression, InputText: string): integer;
var
 R: TRegExpr;
begin
 R := TRegExpr.Create;
 try
   R.Expression := Expression;
 
   if R.Exec(InputText) then
     Result := R.MatchPos[0]
   else
     Result := 0;
 finally
   R.Free;
 end;
end;


Then changing all ? and * with [0-9a-f] but no result .

Please is there any help ?.

Many thanks .

Автор: randy 19.11.2008, 02:20
UP

Автор: MetalFan 19.11.2008, 17:34
maybe u must use regexpr like this:

Код

[0-9A-F]* for replace "*"
or
[0-9A-F] for replace "?"

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)