Re: regExp

From: Gerry Hickman (gerry666uk_at_yahoo.co.uk)
Date: 01/11/05


Date: Tue, 11 Jan 2005 23:03:55 +0000

Hi McKirahan,

> What don't you like? Do you have an alternative?
>
> It uses ReadAll() to store the entire log file into an array then it uses
> Split() to build an array containing each line which are examined one at a
> time.

Here are some things that crossed my mind:

1. ReadAll() is not suitable for "find" style log parsing because it's
not sequential file access. It reads the whole file. I'd have thought
ReadLine() would be more appropriate, and far less memory intensive.

2. The InStr() appears to operate on the whole line, whereas the RegExp
could operate on the beginning of the line. Should be more efficient.

3. The validation would be much more concise with RegExp. For example
the validation on the string of numbers in your script only tests the
length of the string, it does not test whether they are actually numbers
- what if he types 12345b7890 by mistake? Same with the date, the
separators could be tested. The RegExp also makes it very easy to choose
case-sensitivity by changing just one character.

Of course if it's just a script for Juan to run himself, none of this
will matter too much, but if it's a "real" application then it's worth
it, and I often find it saves time a few months down the line when you
can just copy/paste the functionality into a new bigger script instead
of having to re-write it.

-- 
Gerry Hickman (London UK)


Relevant Pages

  • Re: Timestamp Logon/logoff
    ... I don't see how any element of the array could include carriage ... A possible solution would be to replace any carriage returns with blanks: ... The script you have is great. ... The log file is designed to be imported into a spreadsheet for ...
    (microsoft.public.windows.server.scripting)
  • Re: modifying putty to include the symmetric key in the logs
    ... 'keyspace' is an array of 'unsigned char' values, ... Of course such an attacker would become able to ... logged in cleartext _in_ the log file, so an attacker able to read ...
    (comp.security.ssh)
  • New to Perl. Need some guidance with what to do..
    ... I have a log file which tracks orders that are placed. ... that order will be given a unique identifier. ... customers decides to change the order, the replaced order will be given a ... Well, I can get the first two ids into the array, but I am not ...
    (comp.lang.perl.misc)
  • Re: annoying dhclient error messages
    ... > connection. ... The problem is that I get the following annoying error ... > bytes at end of array ... into a new log file, and block them from the console. ...
    (freebsd-questions)
  • Re: Using sortrows on mixed-type cell arrays
    ... I read the log file into a Matlab cell array, everthing is string ... I now want to sort the rows of the array first by then ...
    (comp.soft-sys.matlab)