Re: regExp
From: Gerry Hickman (gerry666uk_at_yahoo.co.uk)
Date: 01/11/05
- Next message: Gerry Hickman: "Re: Wscript.Network without mapping drives?"
- Previous message: Peter: "Re: not getting mapped drive from this script"
- In reply to: McKirahan: "Re: regExp"
- Next in thread: Juan: "Re: regExp"
- Messages sorted by: [ date ] [ thread ]
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)
- Next message: Gerry Hickman: "Re: Wscript.Network without mapping drives?"
- Previous message: Peter: "Re: not getting mapped drive from this script"
- In reply to: McKirahan: "Re: regExp"
- Next in thread: Juan: "Re: regExp"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|