i've been test the RegEx component i download from
http://www.regular-expressions.info/delphi.html, it works well on matching
string but since i new to Regular Expression i need a sample code that can
pull out matching string from file and place it in the listbox (or other
component). so if anyone have a working sample, please share it :D
PS: code should work on binary or text file
thanks
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
It's a superb product that should help you get your job done.
Goog
"Deli Soetiawan" <crushf...@gmail.com> wrote in message
news:op.ueshwyctr9wvmw@loggic-prog...
--
Nick Hodges
Delphi Product Manager - Embarcadero
http://blogs.codegear.com/nickhodges
Who is Goog?
> Have a look at
> http://www.regexbuddy.com/
> It's a superb product that should help you get your job done.
what i mean was actual code for regex from file, maybe something like:
AssignFile(Fn, 'test.dat');
Reset(Fn);
While not Eof(Fn) do
begin
ReadLn(Fn, Data);
PerlRegEx.Subject := Data;
PerlRegEx.Match;
ListBox.Items.Add(PerlRegEx.MatchedExpression);
end;
CloseFile(Fn);
yeah something like reading all files and pull out match pattern from it,
i can do it with readln but it was to slow,
i can do with BlockRead but since the buffer was a array (like
array[1..512] of char) the regex can't get much match, if only anyone have
sample with FileStream or TStream it would be nice (kinda hard to find
reference about it in Win32, all i got was reference for .NET)
It's like 25 Euro for no source, and 75 Euro for source version. That should do what you want and has good documentation.
procedure TgbGoogle.ParseNaturalListings;
begin
RegEx.Regex :=
'(?i)href="HTTP://(www\.)?([_a-z\d\-]+(\.[_a-z\d\-]+)?)/?"';
RegEx.Subject := ResponseHTML;
if RegEx.Match then
repeat
Kind := 1;
ResultHostName := LowerCase(RegEx.SubExpressions[2]);
AddSearchTermAreaResult;
until not RegEx.MatchAgain;
end;
RegEx is a property of type TPerlRegEx. Its Regex property gets assigned the
regular expression string, and its subject takes on the value of an entire
google results page represented as a string. Its Match method is called to
populate the ResultHostName property with the result of the second
subexpression. This continues until there are no more matches.
Since I suck at writing regular expressions, I use RegEx Buddy to help.
I hope this example helps you along. In your example, I think you might use
the TFileStream class to load the entire file into a stream, then, transfer
the contents of the stream to a string variable to use as the regex's
Subject property.
Goog
"Deli Soetiawan" <crushf...@gmail.com> wrote in message
news:op.uetpwlv8r9wvmw@loggic-prog...
yes i have tried it, i even made demo application using that component
(based on SearchStream demo they have) just too bad, it was shareware, i
use my application for education purpose so i have to turn into freeware
component :D there was two freeware regex component, one was TRegExp from
regexpstudio.com and next was TPerlRegExp (i currently use for now)
> I hope this example helps you along. In your example, I think you might
> use the TFileStream class to load the entire file into a stream, then,
> transfer the contents of the stream to a string variable to use as the
> regex's Subject property.
thanks for the code sample, it's very helpfull, btw what you told was
right, load entire file into a stream and use it as regex subject.
too bad the file was around 100 mb and it takes memory for assigning
entire file into a stream, btw it's ok, i just have to figure out how to
solve em.
take alook RegExBuddy, it can regex entire file in fast time :D, i just
dunno how to do em
or maybe i can open file in TMemo and start RegEx TMemo.Lines...