Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: regex: extract multiple number of date patterns from certain lines

by Random_Walk (Prior)
on Mar 04, 2009 at 19:34 UTC ( #748293=note: print w/replies, xml ) Need Help??

in reply to Re: regex: extract multiple number of date patterns from certain lines
in thread regex: extract multiple number of date patterns from certain lines

Hi Marshall

I do need the initial date, this is for of a logfile parser that captures these dates and sends them up the line to a monitoring application that then compares the timestamp date to the processed dates and raises an alarm a processed dates was too old.

The crux of the matter is that my log file parser has one shot at each log line with a regex and the matched parts are then passed up to the next stage, I want to get as much done in the regex as possible/reasonable, partly on the principle of keeping monitoring close to the monitored and partly for pure bloody minded IT geek fun.

sadly the main constraint of this problem is one line of regex, code is cheating!


Pereant, qui ante nos nostra dixerunt!
  • Comment on Re^2: regex: extract multiple number of date patterns from certain lines

Replies are listed 'Best First'.
Re^3: regex: extract multiple number of date patterns from certain lines
by Marshall (Monsignor) on Mar 04, 2009 at 22:00 UTC
    So, if I understand this correctly, you are saying that my code works, but there is some constraint that it has to be in one single regex? If that's the case, then we are into some obfuscated code problem and this is perhaps the wrong place?

    If we are talking about clarity and performance, then that's different. Fewer lines of Perl code doesn't always equal faster performance. I simplified this stuff like must match exactly 4 times, etc. This speeds up the regex engine. As far as clarity goes, I would struggle to be more clear (I'm not a guru).

    If you are interested in performance, then measure and test performance (run benchmarks).

    Counting the number of lines of source code is a relatively poor predictor of actual code performance.

    Update: Well it just took some few seconds to get a negative vote on this post. I was genuinely trying to help with the original problem. I don't understand this requirement for "one line". I think that benchmarking and testing is the right way to go. I would be happy to help in this regard.

      Hi Marshall

      There is actually a constraint that it has to be a single regex, see my answer to Ikegami at Re^2: regex: extract multiple number of date patterns from certain lines to see more of the context in which I am operating.

      As for XP, I did not vote you down but there are some grumpy monks around with itchy trigger fingers, I got -- for every single reply in this thread. Don't worry about it too much, sometimes you get a little hit but is normally tends upwards.


      Pereant, qui ante nos nostra dixerunt!
        Hi, I am trying to be helpful, not just argumentative just for the sake of arguing. I looked at this:

        I have no experience at all with this module. But it looks like you can call a sub when a new line appears and that sub can do what it wants with that line. Maybe my impression is wrong somehow..That's always possible!.

        I do have some experience with regex (and I'm not a regex guru by any means!). But my experience with this is that 2 regex's that don't backtrack, don't use fancy look forward features, will run faster than a single fancy regex. There are also differences between say Perl 5.6 and Perl 5.10 regex engines! Perl 5.10 is much faster if that matters to you or you can take advantage of that.

        Your problem: date1 garbage qualifying_text date2,date3,date4... fits very nicely into the algorithm of skip the lines that don't have the qualifying_text and use match global for the dates on the lines that do have the qualifying_text.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://748293]
[erix]: "code of someone that died" -- kinda nice if your code stops working too
[erix]: hard to implement, hmm
[Corion]: erix: Well, they also seem to have changed the server, or some software, or whatever, and seem to be in the process of changing the DB schema from having the "username" as primary key to something else.
[Corion]: Far too many things being done at once, or maybe only now has it become apparent that nobody knows that piece of software anymore
[marto]: good morning all
[Corion]: I consider having an abstract key as userid in your system good, because the "real" company-wide (or even larger) user id will likely not fit your criteria well
[Corion]: A good morning marto!

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2017-01-23 09:35 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (192 votes). Check out past polls.