Re: please advise help with regex




Gregory Machin top posts (please don't):

On 9/28/06, Rob Dixon <rob.dixon@xxxxxxx> wrote:

28-Sep-2006 10:10:57.266update: info: client 192.168.1.170#33364: view
internal: updating zone 'lan.linserv.co.za/IN': adding an RR at '
greg.lan.linserv.co.za' A"

i have been playing... will this work and wich is more efficient ?

/^([0-3][0-9]\-
#day -----|
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+ #month
|
\-(20)[0-9][0-9]\s+
#year till 2099 |
[0-9][0-9]\:
#hour |= date and time
[0-9][0-9]\:
#miniute |
[0-9][0-9]\:)
#hour -----|
((\.\d{3})?
#milliseconds
(\w\:)
#catagory ----- catagory
(\s+\w\:)
#severity ----- serverity
(\w\s+)
#host ----- host
(s+\d+\.\d+\.\d+\.\d+)
#ip ----- ip
(\#\d+/i)
#port ----- port
(\:\s+\s\w\s\w\:) #view
----- view
(\s+[:alpha:]/) #query
----- query



Why are you working so damn hard?

What's with the ---- ?

[0-9] can be written \d every time.

There's no need to escape colons

\w matches a single character \w+ matches a "word".

\S+ will match any seqence of non-whitespace.

Unless you are trying to validate the data you can use a far more
liberal pattern.

my ($date,$time,$catagory,$severity, $host, $ip, $port, $view, $query)
=
/^(\S+) (\S+\.\d+)(\S+): (\S+): (\S+) (\S+)#(\d+): view (\S+):
(.*)/;

.



Relevant Pages

  • Re: please advise help with regex
    ... Is there really nothing at all between the milliseconds ... It works by splitting on, as I said, colon and whitespace, and then ... You also seem to want the client field ... updating zone 'lan.linserv.co.za/IN': ...
    (perl.beginners)
  • Re: removing single quotation marks from a string ?
    ... quick look and see what i'm missing ... ... 196.211.85.42#35435: view external: updating zone ... use Mysql; ... On 11/16/06, Gregory Machin wrote: ...
    (perl.beginners)